]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: hwbm: Fix unbalanced spinlock in error case
authorGregory CLEMENT <gregory.clement@free-electrons.com>
Tue, 24 May 2016 16:03:26 +0000 (18:03 +0200)
committerDavid S. Miller <davem@davemloft.net>
Wed, 25 May 2016 19:35:09 +0000 (12:35 -0700)
When hwbm_pool_add exited in error the spinlock was not released. This
patch fixes this issue.

Fixes: 3a5a718a35de ("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>
net/core/hwbm.c

index 941c284868966971fb685e68e71878f5c2185d80..2cab489ae62e657c2ec99cca71b558d9a3b3cf7a 100644 (file)
@@ -55,18 +55,21 @@ int hwbm_pool_add(struct hwbm_pool *bm_pool, unsigned int buf_num, gfp_t gfp)
        spin_lock_irqsave(&bm_pool->lock, flags);
        if (bm_pool->buf_num == bm_pool->size) {
                pr_warn("pool already filled\n");
+               spin_unlock_irqrestore(&bm_pool->lock, flags);
                return bm_pool->buf_num;
        }
 
        if (buf_num + bm_pool->buf_num > bm_pool->size) {
                pr_warn("cannot allocate %d buffers for pool\n",
                        buf_num);
+               spin_unlock_irqrestore(&bm_pool->lock, flags);
                return 0;
        }
 
        if ((buf_num + bm_pool->buf_num) < bm_pool->buf_num) {
                pr_warn("Adding %d buffers to the %d current buffers will overflow\n",
                        buf_num,  bm_pool->buf_num);
+               spin_unlock_irqrestore(&bm_pool->lock, flags);
                return 0;
        }