Skip to contentSkip to conversation

xsk: Free variable on error path

PATCH In review Alex Dewar 2 participants 2 messages Sep 2, 2020

Subsystems (4)
lore
Share & tools
lore

Alex Dewar

author
#0 lore raw

PATCH 1/1 xsk: Free variable on error path

In xp_create_dma_map(), memory is allocated to dma_map->dma_pages, but then dma_map is erroneously compared to NULL, rather than the member. Fix this.

Addresses-Coverity: ("Dead code")

Fixes 921b68692abb ("xsk: Enable sharing of dma mappings")
---
 net/xdp/xsk_buff_pool.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/xdp/xsk_buff_pool.c +1 -1
index 795d7c81c0ca..5b00bc5707f2 100644
@@ -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;
 	}
Signature · 1 line
2.28.0
maintainer
#1 lore raw
Quoted 7 lines · Alex Dewar

In xp_create_dma_map(), memory is allocated to dma_map->dma_pages, but then dma_map is erroneously compared to NULL, rather than the member. Fix this.

Addresses-Coverity: ("Dead code")

Fixes 921b68692abb ("xsk: Enable sharing of dma mappings")

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