2020-09-02 15:43:36

by Gustavo A. R. Silva

[permalink] [raw]
Subject: [PATCH][next] 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")
Signed-off-by: Gustavo A. R. Silva <[email protected]>
---
net/xdp/xsk_buff_pool.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

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;
}
--
2.27.0


2020-09-02 18:37:08

by Daniel Borkmann

[permalink] [raw]
Subject: Re: [PATCH][next] xsk: Fix null check on error return path

On 9/2/20 5:07 PM, Gustavo A. R. Silva wrote:
> 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")
> Signed-off-by: Gustavo A. R. Silva <[email protected]>

Applied, thanks!

2020-09-02 19:13:16

by Gustavo A. R. Silva

[permalink] [raw]
Subject: Re: [PATCH][next] xsk: Fix null check on error return path

On Wed, Sep 02, 2020 at 08:33:41PM +0200, Daniel Borkmann wrote:
> On 9/2/20 5:07 PM, Gustavo A. R. Silva wrote:
> > 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")
> > Signed-off-by: Gustavo A. R. Silva <[email protected]>
>
> Applied, thanks!

Thanks, Daniel. :)

--
Gustavo