All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Jones <davej@redhat.com>
To: linux-scsi@vger.kernel.org
Subject: libsrp: remove unreachable kfree
Date: Thu, 30 Jan 2014 14:19:07 -0500	[thread overview]
Message-ID: <20140130191907.GA13810@redhat.com> (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.

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)

                 reply	other threads:[~2014-01-30 19:19 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140130191907.GA13810@redhat.com \
    --to=davej@redhat.com \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.