linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* libsrp: remove unreachable kfree
@ 2014-01-30 19:19 Dave Jones
  0 siblings, 0 replies; only message in thread
From: Dave Jones @ 2014-01-30 19:19 UTC (permalink / raw)
  To: linux-scsi

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.

Signed-off-by: Dave Jones <davej@fedoraproject.org>

diff --git a/drivers/scsi/libsrp.c b/drivers/scsi/libsrp.c
index 0707ecdbaa32..f45758f15381 100644
--- a/drivers/scsi/libsrp.c
+++ b/drivers/scsi/libsrp.c
@@ -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)

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2014-01-30 19:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-30 19:19 libsrp: remove unreachable kfree Dave Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).