Skip to content

Commit bf74a37

Browse files
magnus-karlssonAlexei Starovoitov
authored and
Alexei Starovoitov
committed
xsk: Fix refcount warning in xp_dma_map
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: 921b686 ("xsk: Enable sharing of dma mappings") Signed-off-by: Magnus Karlsson <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Acked-by: Song Liu <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 74e0067 commit bf74a37

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

net/xdp/xsk_buff_pool.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ static struct xsk_dma_map *xp_create_dma_map(struct device *dev, struct net_devi
296296
dma_map->dev = dev;
297297
dma_map->dma_need_sync = false;
298298
dma_map->dma_pages_cnt = nr_pages;
299-
refcount_set(&dma_map->users, 0);
299+
refcount_set(&dma_map->users, 1);
300300
list_add(&dma_map->list, &umem->xsk_dma_list);
301301
return dma_map;
302302
}
@@ -369,7 +369,6 @@ static int xp_init_dma_info(struct xsk_buff_pool *pool, struct xsk_dma_map *dma_
369369
pool->dev = dma_map->dev;
370370
pool->dma_pages_cnt = dma_map->dma_pages_cnt;
371371
pool->dma_need_sync = dma_map->dma_need_sync;
372-
refcount_inc(&dma_map->users);
373372
memcpy(pool->dma_pages, dma_map->dma_pages,
374373
pool->dma_pages_cnt * sizeof(*pool->dma_pages));
375374

@@ -390,6 +389,7 @@ int xp_dma_map(struct xsk_buff_pool *pool, struct device *dev,
390389
if (err)
391390
return err;
392391

392+
refcount_inc(&dma_map->users);
393393
return 0;
394394
}
395395

0 commit comments

Comments
 (0)