Skip to content

Commit

Permalink
net/af_xdp: fix memzone leak on config failure
Browse files Browse the repository at this point in the history
[ upstream commit 960775fc5b7d43cfbf9fa31e4c0b36c4da79615a ]

In xdp_umem_configure() allocated memzone for the 'umem', we should
free it when xsk_umem__create() call fails, otherwise it will lead to
memory zone leak. To fix it move 'umem->mz = mz;' assignment after
'mz == NULL' check.

Fixes: f1debd7 ("net/af_xdp: introduce AF_XDP PMD")

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Acked-by: Ciara Loftus <ciara.loftus@intel.com>
Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
  • Loading branch information
wyjwang authored and bluca committed Mar 7, 2024
1 parent bc1e0ee commit 173ff75
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/net/af_xdp/rte_eth_af_xdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1211,6 +1211,7 @@ xsk_umem_info *xdp_umem_configure(struct pmd_internals *internals,
AF_XDP_LOG(ERR, "Failed to reserve memzone for af_xdp umem.\n");
goto err;
}
umem->mz = mz;

ret = xsk_umem__create(&umem->umem, mz->addr,
ETH_AF_XDP_NUM_BUFFERS * ETH_AF_XDP_FRAME_SIZE,
Expand All @@ -1221,7 +1222,6 @@ xsk_umem_info *xdp_umem_configure(struct pmd_internals *internals,
AF_XDP_LOG(ERR, "Failed to create umem\n");
goto err;
}
umem->mz = mz;

return umem;

Expand Down

0 comments on commit 173ff75

Please sign in to comment.