diff mbox series

[next] xsk: fix incorrect memory allocation failure check on dma_map->dma_pages

Message ID 20200902161332.199961-1-colin.king@canonical.com
State New
Headers show
Series [next] xsk: fix incorrect memory allocation failure check on dma_map->dma_pages | expand

Commit Message

Colin King Sept. 2, 2020, 4:13 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

The failed memory allocation check for dma_map->dma_pages is incorrect,
it is null checking dma_map and not dma_map->dma_pages. Fix this.

Addresses-Coverity: ("Logicall dead code")
Fixes: 921b68692abb ("xsk: Enable sharing of dma mappings")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 net/xdp/xsk_buff_pool.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Daniel Borkmann Sept. 2, 2020, 6:35 p.m. UTC | #1
On 9/2/20 6:13 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The failed memory allocation check for dma_map->dma_pages is incorrect,
> it is null checking dma_map and not dma_map->dma_pages. Fix this.
> 
> Addresses-Coverity: ("Logicall dead code")
> Fixes: 921b68692abb ("xsk: Enable sharing of dma mappings")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Thanks, already applied a fix that was sent earlier [0].

   [0] https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/commit/?id=1d6fd78a213ee3874f46bdce083b7a41d208886d
diff mbox series

Patch

diff --git a/net/xdp/xsk_buff_pool.c b/net/xdp/xsk_buff_pool.c
index 795d7c81c0ca..5b00bc5707f2 100644
--- a/net/xdp/xsk_buff_pool.c
+++ b/net/xdp/xsk_buff_pool.c
@@ -287,7 +287,7 @@  static struct xsk_dma_map *xp_create_dma_map(struct device *dev, struct net_devi
 		return NULL;
 
 	dma_map->dma_pages = kvcalloc(nr_pages, sizeof(*dma_map->dma_pages), GFP_KERNEL);
-	if (!dma_map) {
+	if (!dma_map->dma_pages) {
 		kfree(dma_map);
 		return NULL;
 	}