mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH][Resend] SCSI, target, loopback: Fix memory leak in tcm_loop_make_scsi_hba()
@ 2011-06-27 21:54 Jesper Juhl
  2011-06-27 22:25 ` Dan Carpenter
  0 siblings, 1 reply; 5+ messages in thread
From: Jesper Juhl @ 2011-06-27 21:54 UTC (permalink / raw)
  To: Nicholas A. Bellinger
  Cc: James Bottomley, Dan Carpenter, Christoph Hellwig, linux-scsi,
	linux-kernel

There is a memory leak in tcm_loop_make_scsi_hba().

If all the strstr() calls return NULL and we end up at
 return ERR_PTR(-EINVAL);
then we'll be leaking the memory previously allocated to tl_hba as
that variable goes out of scope.

This patch should fix the leak.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
---
 drivers/target/loopback/tcm_loop.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

  Compile tested only.
  Last submitted April 07, 2011

diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c
index 70c2e7f..aa3bb70 100644
--- a/drivers/target/loopback/tcm_loop.c
+++ b/drivers/target/loopback/tcm_loop.c
@@ -1321,7 +1321,8 @@ struct se_wwn *tcm_loop_make_scsi_hba(
 
 	printk(KERN_ERR "Unable to locate prefix for emulated Target Port:"
 			" %s\n", name);
-	return ERR_PTR(-EINVAL);
+	ret = -EINVAL;
+	goto out;
 
 check_len:
 	if (strlen(name) >= TL_WWN_ADDR_LEN) {
-- 
1.7.5.2


-- 
Jesper Juhl <jj@chaosbits.net>       http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-07-17 21:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-27 21:54 [PATCH][Resend] SCSI, target, loopback: Fix memory leak in tcm_loop_make_scsi_hba() Jesper Juhl
2011-06-27 22:25 ` Dan Carpenter
2011-06-27 22:30   ` Jesper Juhl
2011-06-28  6:22     ` Dan Carpenter
2011-07-17 20:59       ` Nicholas A. Bellinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®