From f4ebcb1e70879fd90bc21f93e6740f054d71f94c Mon Sep 17 00:00:00 2001 From: Horia Geanta Date: Tue, 20 May 2014 14:44:52 +0300 Subject: fsl_qbman: fix access to alloc->used list in DPA allocator The operation of adding the newly allocated node in alloc->used list must be protected by the alloc->lock. Change-Id: I8f80006b59102dd4563f36d0d196afe3c5307489 Signed-off-by: Horia Geanta Tested-by: Mircea Pop Reviewed-on: http://git.am.freescale.net:8181/12525 Reviewed-by: Alexandru Porosanu Tested-by: Review Code-CDREVIEW Reviewed-by: Bogdan Hamciuc Reviewed-by: Jose Rivera diff --git a/drivers/staging/fsl_qbman/dpa_alloc.c b/drivers/staging/fsl_qbman/dpa_alloc.c index 545adc9..2468a97 100644 --- a/drivers/staging/fsl_qbman/dpa_alloc.c +++ b/drivers/staging/fsl_qbman/dpa_alloc.c @@ -498,8 +498,10 @@ done: list_del(&i->list); kfree(i); *result = base; + } else { + spin_unlock_irq(&alloc->lock); } - spin_unlock_irq(&alloc->lock); + err: DPRINT("returning %d\n", i ? num : -ENOMEM); DUMP(alloc); @@ -508,13 +510,16 @@ err: /* Add the allocation to the used list with a refcount of 1 */ used_node = kmalloc(sizeof(*used_node), GFP_KERNEL); - if (!used_node) + if (!used_node) { + spin_unlock_irq(&alloc->lock); return -ENOMEM; + } used_node->base = *result; used_node->num = num; used_node->refcount = 1; used_node->is_alloced = 1; list_add_tail(&used_node->list, &alloc->used); + spin_unlock_irq(&alloc->lock); return (int)num; } -- cgit v0.10.2