Skip to content

Commit 217f97e

Browse files
committed
Merge branch 'hwbm-locking-fixes'
Gregory CLEMENT says: ==================== Fix spinlock usage in HWBM these two patches fix spinlock related issues introduced in v4.6. They have been reported by Russell King and Jean-Jacques Hiblot. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 297f7d2 + b388fc7 commit 217f97e

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

drivers/net/ethernet/marvell/mvneta_bm.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ struct mvneta_bm_pool *mvneta_bm_pool_use(struct mvneta_bm *priv, u8 pool_id,
189189
SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
190190
hwbm_pool->construct = mvneta_bm_construct;
191191
hwbm_pool->priv = new_pool;
192+
spin_lock_init(&hwbm_pool->lock);
192193

193194
/* Create new pool */
194195
err = mvneta_bm_pool_create(priv, new_pool);

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)