Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 8cb2d8bf57e6 ("net: add a hardware buffer management helper API")
Reported-by: Jean-Jacques Hiblot <jjhiblot@traphandler.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Gregory CLEMENT and committed by
David S. Miller
b388fc74 91c45e38

+3
+3
net/core/hwbm.c
··· 55 55 spin_lock_irqsave(&bm_pool->lock, flags); 56 56 if (bm_pool->buf_num == bm_pool->size) { 57 57 pr_warn("pool already filled\n"); 58 + spin_unlock_irqrestore(&bm_pool->lock, flags); 58 59 return bm_pool->buf_num; 59 60 } 60 61 61 62 if (buf_num + bm_pool->buf_num > bm_pool->size) { 62 63 pr_warn("cannot allocate %d buffers for pool\n", 63 64 buf_num); 65 + spin_unlock_irqrestore(&bm_pool->lock, flags); 64 66 return 0; 65 67 } 66 68 67 69 if ((buf_num + bm_pool->buf_num) < bm_pool->buf_num) { 68 70 pr_warn("Adding %d buffers to the %d current buffers will overflow\n", 69 71 buf_num, bm_pool->buf_num); 72 + spin_unlock_irqrestore(&bm_pool->lock, flags); 70 73 return 0; 71 74 } 72 75