[PATCH bpf-next] xsk: fix refcount warning in xp_dma_map

Subsystems: networking [general], the rest, xdp sockets (af_xdp)

STALE2147d LANDED

Landed in mainline as bf74a370eb40 on 2020-09-15.

3 messages, 3 authors, 2020-09-15 · open the first message on its own page

[PATCH bpf-next] xsk: fix refcount warning in xp_dma_map

From: Magnus Karlsson <hidden>
Date: 2020-09-14 14:51:48

From: Magnus Karlsson <magnus.karlsson@intel.com>

Fix a potential refcount warning that a zero value is increased to one
in xp_dma_map, by initializing the refcount to one to start with,
instead of zero plus a refcount_inc().

Fixes: 921b68692abb ("xsk: Enable sharing of dma mappings")
Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
---
 net/xdp/xsk_buff_pool.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/xdp/xsk_buff_pool.c b/net/xdp/xsk_buff_pool.c
index 5b00bc5..e63fadd 100644
--- a/net/xdp/xsk_buff_pool.c
+++ b/net/xdp/xsk_buff_pool.c
@@ -296,7 +296,7 @@ static struct xsk_dma_map *xp_create_dma_map(struct device *dev, struct net_devi
 	dma_map->dev = dev;
 	dma_map->dma_need_sync = false;
 	dma_map->dma_pages_cnt = nr_pages;
-	refcount_set(&dma_map->users, 0);
+	refcount_set(&dma_map->users, 1);
 	list_add(&dma_map->list, &umem->xsk_dma_list);
 	return dma_map;
 }
@@ -369,7 +369,6 @@ static int xp_init_dma_info(struct xsk_buff_pool *pool, struct xsk_dma_map *dma_
 	pool->dev = dma_map->dev;
 	pool->dma_pages_cnt = dma_map->dma_pages_cnt;
 	pool->dma_need_sync = dma_map->dma_need_sync;
-	refcount_inc(&dma_map->users);
 	memcpy(pool->dma_pages, dma_map->dma_pages,
 	       pool->dma_pages_cnt * sizeof(*pool->dma_pages));
 
@@ -390,6 +389,7 @@ int xp_dma_map(struct xsk_buff_pool *pool, struct device *dev,
 		if (err)
 			return err;
 
+		refcount_inc(&dma_map->users);
 		return 0;
 	}
 
-- 
2.7.4

Re: [PATCH bpf-next] xsk: fix refcount warning in xp_dma_map

From: Song Liu <song@kernel.org>
Date: 2020-09-14 21:13:36

On Mon, Sep 14, 2020 at 7:52 AM Magnus Karlsson
[off-list ref] wrote:
From: Magnus Karlsson <magnus.karlsson@intel.com>

Fix a potential refcount warning that a zero value is increased to one
in xp_dma_map, by initializing the refcount to one to start with,
instead of zero plus a refcount_inc().

Fixes: 921b68692abb ("xsk: Enable sharing of dma mappings")
Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
Acked-by: Song Liu <redacted>

Re: [PATCH bpf-next] xsk: fix refcount warning in xp_dma_map

From: Alexei Starovoitov <hidden>
Date: 2020-09-15 01:46:22

On Mon, Sep 14, 2020 at 2:13 PM Song Liu [off-list ref] wrote:
On Mon, Sep 14, 2020 at 7:52 AM Magnus Karlsson
[off-list ref] wrote:
quoted
From: Magnus Karlsson <magnus.karlsson@intel.com>

Fix a potential refcount warning that a zero value is increased to one
in xp_dma_map, by initializing the refcount to one to start with,
instead of zero plus a refcount_inc().

Fixes: 921b68692abb ("xsk: Enable sharing of dma mappings")
Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
Acked-by: Song Liu <redacted>
Applied. Thanks
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help