Skip to contentSkip to conversation

xsk: Fix null check on error return path

PATCH Applied Gustavo A. R. Silva 3 participants 5 messages Sep 2, 2020

Subsystems (4)
lore
Share & tools
lore
Acked-by on v1 1/1
#1 lore raw
In reply to Gustavo A. R. Silva
Quoted 8 lines · Gustavo A. R. Silva

Currently, dma_map is being checked, when the right object identifier to be null-checked is dma_map->dma_pages, instead.

Fix this by null-checking dma_map->dma_pages.

Addresses-Coverity-ID: 1496811 ("Logically dead code")

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

Nice catch!

Quoted 18 lines
---
  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;
  	}
#0 lore raw

PATCH 1/1 xsk: Fix null check on error return path

Currently, dma_map is being checked, when the right object identifier to be null-checked is dma_map->dma_pages, instead.

Fix this by null-checking dma_map->dma_pages.

Addresses-Coverity-ID: 1496811 ("Logically 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.27.0
#2 lore raw
In reply to Björn Töpel
Quoted 6 lines · Björn Töpel
Quoted 5 lines · Gustavo A. R. Silva

Currently, dma_map is being checked, when the right object identifier to be null-checked is dma_map->dma_pages, instead.

Fix this by null-checking dma_map->dma_pages.

Quoted 8 lines
Quoted 3 lines

Addresses-Coverity-ID: 1496811 ("Logically dead code")

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

Nice catch!

Thanks, Björn.

--
Gustavo

Quoted 17 lines
Quoted 17 lines
---
  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;
  	}
 
maintainer Applied
#3 lore raw
In reply to Gustavo A. R. Silva
Quoted 8 lines · Gustavo A. R. Silva

Currently, dma_map is being checked, when the right object identifier to be null-checked is dma_map->dma_pages, instead.

Fix this by null-checking dma_map->dma_pages.

Addresses-Coverity-ID: 1496811 ("Logically dead code")

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

Applied, thanks!

#4 lore raw
Quoted 11 lines · Daniel Borkmann
Quoted 8 lines · Gustavo A. R. Silva

Currently, dma_map is being checked, when the right object identifier to be null-checked is dma_map->dma_pages, instead.

Fix this by null-checking dma_map->dma_pages.

Addresses-Coverity-ID: 1496811 ("Logically dead code")

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

Applied, thanks!

Thanks, Daniel. :)

--
Gustavo