Skip to content

Commit b388fc7

Browse files
gclementdavem330
authored andcommitted
net: hwbm: Fix unbalanced spinlock in error case
When hwbm_pool_add exited in error the spinlock was not released. This patch fixes this issue. Fixes: 8cb2d8b ("net: add a hardware buffer management helper API") Reported-by: Jean-Jacques Hiblot <[email protected]> Cc: <[email protected]> Signed-off-by: Gregory CLEMENT <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 91c45e3 commit b388fc7

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

net/core/hwbm.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,21 @@ int hwbm_pool_add(struct hwbm_pool *bm_pool, unsigned int buf_num, gfp_t gfp)
5555
spin_lock_irqsave(&bm_pool->lock, flags);
5656
if (bm_pool->buf_num == bm_pool->size) {
5757
pr_warn("pool already filled\n");
58+
spin_unlock_irqrestore(&bm_pool->lock, flags);
5859
return bm_pool->buf_num;
5960
}
6061

6162
if (buf_num + bm_pool->buf_num > bm_pool->size) {
6263
pr_warn("cannot allocate %d buffers for pool\n",
6364
buf_num);
65+
spin_unlock_irqrestore(&bm_pool->lock, flags);
6466
return 0;
6567
}
6668

6769
if ((buf_num + bm_pool->buf_num) < bm_pool->buf_num) {
6870
pr_warn("Adding %d buffers to the %d current buffers will overflow\n",
6971
buf_num, bm_pool->buf_num);
72+
spin_unlock_irqrestore(&bm_pool->lock, flags);
7073
return 0;
7174
}
7275

0 commit comments

Comments
 (0)