[SCSI] bfa: dereferencing freed memory in bfad_im_probe()

If bfad_thread_workq(bfad) was not BFA_STATUS_OK then we freed "im"
and then dereferenced it.

I did a little clean up because it seemed nicer to return directly
instead of doing a superfluous goto.  I looked at other functions in
this file and it seems like returning directly is standard.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Krishna Gudipati <kgudipat@brocade.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
This commit is contained in:
Dan Carpenter 2012-06-27 11:59:58 +03:00 committed by James Bottomley
parent fffa69230b
commit a5254dbb17

View File

@ -687,25 +687,21 @@ bfa_status_t
bfad_im_probe(struct bfad_s *bfad) bfad_im_probe(struct bfad_s *bfad)
{ {
struct bfad_im_s *im; struct bfad_im_s *im;
bfa_status_t rc = BFA_STATUS_OK;
im = kzalloc(sizeof(struct bfad_im_s), GFP_KERNEL); im = kzalloc(sizeof(struct bfad_im_s), GFP_KERNEL);
if (im == NULL) { if (im == NULL)
rc = BFA_STATUS_ENOMEM; return BFA_STATUS_ENOMEM;
goto ext;
}
bfad->im = im; bfad->im = im;
im->bfad = bfad; im->bfad = bfad;
if (bfad_thread_workq(bfad) != BFA_STATUS_OK) { if (bfad_thread_workq(bfad) != BFA_STATUS_OK) {
kfree(im); kfree(im);
rc = BFA_STATUS_FAILED; return BFA_STATUS_FAILED;
} }
INIT_WORK(&im->aen_im_notify_work, bfad_aen_im_notify_handler); INIT_WORK(&im->aen_im_notify_work, bfad_aen_im_notify_handler);
ext: return BFA_STATUS_OK;
return rc;
} }
void void