aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/bfa
diff options
context:
space:
mode:
authorJesper Juhl <jj@chaosbits.net>2012-01-27 18:23:41 -0500
committerJames Bottomley <JBottomley@Parallels.com>2012-02-19 09:09:01 -0500
commit64b8aa75bc101eb73e2c76a66fb5432b4c83ffb2 (patch)
tree185dcaa9eca3df2d5ab3dce10e42527a28ca4db5 /drivers/scsi/bfa
parente5cc6aa4b6ef34c3f054af8c61a4f73c157589c3 (diff)
[SCSI] bfa: don't leak mem in bfad_im_bsg_els_ct_request()
If 'drv_fcxp = kzalloc(sizeof(struct bfad_fcxp), GFP_KERNEL);' fails and returns NULL, then we'll leak the memory allocated to 'bsg_fcpt' when we jump to 'out:' and the variable subsequently goes out of scope. Also remove the cast of the kzalloc() return value. kzalloc() returns a void* which is implicitly converted, so the explicit cast is pointless. Signed-off-by: Jesper Juhl <jj@chaosbits.net> Acked-by: Krishna Gudipati <kgudipat@brocade.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi/bfa')
-rw-r--r--drivers/scsi/bfa/bfad_bsg.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/scsi/bfa/bfad_bsg.c b/drivers/scsi/bfa/bfad_bsg.c
index 530de2b1200..8005c6c5a08 100644
--- a/drivers/scsi/bfa/bfad_bsg.c
+++ b/drivers/scsi/bfa/bfad_bsg.c
@@ -3047,8 +3047,7 @@ bfad_im_bsg_els_ct_request(struct fc_bsg_job *job)
3047 * Allocate buffer for bsg_fcpt and do a copy_from_user op for payload 3047 * Allocate buffer for bsg_fcpt and do a copy_from_user op for payload
3048 * buffer of size bsg_data->payload_len 3048 * buffer of size bsg_data->payload_len
3049 */ 3049 */
3050 bsg_fcpt = (struct bfa_bsg_fcpt_s *) 3050 bsg_fcpt = kzalloc(bsg_data->payload_len, GFP_KERNEL);
3051 kzalloc(bsg_data->payload_len, GFP_KERNEL);
3052 if (!bsg_fcpt) 3051 if (!bsg_fcpt)
3053 goto out; 3052 goto out;
3054 3053
@@ -3060,6 +3059,7 @@ bfad_im_bsg_els_ct_request(struct fc_bsg_job *job)
3060 3059
3061 drv_fcxp = kzalloc(sizeof(struct bfad_fcxp), GFP_KERNEL); 3060 drv_fcxp = kzalloc(sizeof(struct bfad_fcxp), GFP_KERNEL);
3062 if (drv_fcxp == NULL) { 3061 if (drv_fcxp == NULL) {
3062 kfree(bsg_fcpt);
3063 rc = -ENOMEM; 3063 rc = -ENOMEM;
3064 goto out; 3064 goto out;
3065 } 3065 }