[SCSI] target: Fix memory leak on error path in pscsi_alloc_task
authorRoland Dreier <rolandd@cisco.com>
Mon, 14 Mar 2011 11:05:55 +0000 (04:05 -0700)
committerJames Bottomley <James.Bottomley@suse.de>
Wed, 23 Mar 2011 16:36:18 +0000 (11:36 -0500)
If allocation of pt->pscsi_cdb fails, we need to free the just-allocated
pt or else it will be leaked.

Signed-off-by: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Nicholas A. Bellinger <nab@linux-iscsi.org>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
drivers/target/target_core_pscsi.c

index 5a9d2ba4b609309124f6afdeb9d3a284ff56e116..3031ef8261ef21703be39c30c409fbfc52be29e4 100644 (file)
@@ -816,6 +816,7 @@ pscsi_alloc_task(struct se_cmd *cmd)
                if (!(pt->pscsi_cdb)) {
                        printk(KERN_ERR "pSCSI: Unable to allocate extended"
                                        " pt->pscsi_cdb\n");
+                       kfree(pt);
                        return NULL;
                }
        } else