[<prev] [next>] [day] [month] [year] [list]
Message-ID: <alpine.LNX.2.00.1104072108370.1538@swampdragon.chaosbits.net>
Date: Thu, 7 Apr 2011 21:14:27 +0200 (CEST)
From: Jesper Juhl <jj@...osbits.net>
To: "Nicholas A. Bellinger" <nab@...ux-iscsi.org>
cc: James Bottomley <James.Bottomley@...e.de>,
Christoph Hellwig <hch@....de>, linux-scsi@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] SCSI, target, loopback: Fix memory leak in
tcm_loop_make_scsi_hba()
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 fixes the leak.
Signed-off-by: Jesper Juhl <jj@...osbits.net>
---
tcm_loop.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
compile tested only.
diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c
index aed4e46..c4f81ec 100644
--- a/drivers/target/loopback/tcm_loop.c
+++ b/drivers/target/loopback/tcm_loop.c
@@ -1330,7 +1330,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) {
--
Jesper Juhl <jj@...osbits.net> http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists