Skip to contentSkip to conversation

libsrp: remove unreachable kfree

PATCH Dave Jones 1 participant 1 message Jan 30, 2014 SCSI

lore
Share & tools
lore

Dave Jones

author
#0 lore raw

srp_iu_pool_alloc implements what seems like a standard "common exit path with gotos" but there's only one way to reach it. Additionally the kfree(q->items) is unreachable.

fold the error path back into the if.

drivers/scsi/libsrp.c +5 -7
index 0707ecdbaa32..f45758f15381 100644
@@ -55,9 +55,12 @@ static int srp_iu_pool_alloc(struct srp_queue *q, size_t max,
 	q->pool = kcalloc(max, sizeof(struct iu_entry *), GFP_KERNEL);
 	if (!q->pool)
 		return -ENOMEM;
+
 	q->items = kcalloc(max, sizeof(struct iu_entry), GFP_KERNEL);
-	if (!q->items)
-		goto free_pool;
+	if (!q->items) {
+		kfree(q->pool);
+		return -ENOMEM;
+	}
 
 	spin_lock_init(&q->lock);
 	kfifo_init(&q->queue, (void *) q->pool, max * sizeof(void *));
@@ -68,11 +71,6 @@ static int srp_iu_pool_alloc(struct srp_queue *q, size_t max,
 		iue++;
 	}
 	return 0;
-
-	kfree(q->items);
-free_pool:
-	kfree(q->pool);
-	return -ENOMEM;
 }
 
 static void srp_iu_pool_free(struct srp_queue *q)