summaryrefslogtreecommitdiff
path: root/drivers/target
diff options
context:
space:
mode:
authorJesper Juhl <jj@chaosbits.net>2011-06-28 02:30:17 +0400
committerNicholas Bellinger <nab@linux-iscsi.org>2011-07-22 13:37:46 +0400
commita57b5d36453cc9335f75ae191ffd682a250d08ba (patch)
tree4879b45aec4865ee6c7df64cf7a71b56f75e9238 /drivers/target
parent824cc5ff37a0dc3ec8c9e7002e3b1ca0b408917e (diff)
downloadlinux-a57b5d36453cc9335f75ae191ffd682a250d08ba.tar.xz
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 should fix the leak. Signed-off-by: Jesper Juhl <jj@chaosbits.net> Signed-off-by: Dan Carpenter <error27@gmail.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target')
-rw-r--r--drivers/target/loopback/tcm_loop.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c
index e53cec64ddd4..fe11a336b598 100644
--- a/drivers/target/loopback/tcm_loop.c
+++ b/drivers/target/loopback/tcm_loop.c
@@ -1288,22 +1288,21 @@ struct se_wwn *tcm_loop_make_scsi_hba(
goto check_len;
}
ptr = strstr(name, "iqn.");
- if (ptr) {
- tl_hba->tl_proto_id = SCSI_PROTOCOL_ISCSI;
- goto check_len;
+ if (!ptr) {
+ printk(KERN_ERR "Unable to locate prefix for emulated Target "
+ "Port: %s\n", name);
+ ret = -EINVAL;
+ goto out;
}
-
- printk(KERN_ERR "Unable to locate prefix for emulated Target Port:"
- " %s\n", name);
- return ERR_PTR(-EINVAL);
+ tl_hba->tl_proto_id = SCSI_PROTOCOL_ISCSI;
check_len:
if (strlen(name) >= TL_WWN_ADDR_LEN) {
printk(KERN_ERR "Emulated NAA %s Address: %s, exceeds"
" max: %d\n", name, tcm_loop_dump_proto_id(tl_hba),
TL_WWN_ADDR_LEN);
- kfree(tl_hba);
- return ERR_PTR(-EINVAL);
+ ret = -EINVAL;
+ goto out;
}
snprintf(&tl_hba->tl_wwn_address[0], TL_WWN_ADDR_LEN, "%s", &name[off]);