public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] [SCSI] bfa: dereferencing freed memory in bfad_im_probe()
@ 2011-07-29  8:53 Dan Carpenter
  2011-11-18 13:55 ` Dan Carpenter
  2012-02-29 12:59 ` [resend] " Dan Carpenter
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2011-07-29  8:53 UTC (permalink / raw)
  To: Jing Huang
  Cc: James E.J. Bottomley, open list:BROCADE BFA FC SC...,
	kernel-janitors

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 <error27@gmail.com>

diff --git a/drivers/scsi/bfa/bfad_im.c b/drivers/scsi/bfa/bfad_im.c
index 0131238..7f7cca0 100644
--- a/drivers/scsi/bfa/bfad_im.c
+++ b/drivers/scsi/bfa/bfad_im.c
@@ -685,25 +685,21 @@ bfa_status_t
 bfad_im_probe(struct bfad_s *bfad)
 {
 	struct bfad_im_s      *im;
-	bfa_status_t    rc = BFA_STATUS_OK;
 
 	im = kzalloc(sizeof(struct bfad_im_s), GFP_KERNEL);
-	if (im = NULL) {
-		rc = BFA_STATUS_ENOMEM;
-		goto ext;
-	}
+	if (im = NULL)
+		return BFA_STATUS_ENOMEM;
 
 	bfad->im = im;
 	im->bfad = bfad;
 
 	if (bfad_thread_workq(bfad) != BFA_STATUS_OK) {
 		kfree(im);
-		rc = BFA_STATUS_FAILED;
+		return BFA_STATUS_FAILED;
 	}
 
 	INIT_WORK(&im->aen_im_notify_work, bfad_aen_im_notify_handler);
-ext:
-	return rc;
+	return BFA_STATUS_OK;
 }
 
 void

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [patch] [SCSI] bfa: dereferencing freed memory in bfad_im_probe()
  2011-07-29  8:53 [patch] [SCSI] bfa: dereferencing freed memory in bfad_im_probe() Dan Carpenter
@ 2011-11-18 13:55 ` Dan Carpenter
  2012-02-29 12:59 ` [resend] " Dan Carpenter
  1 sibling, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2011-11-18 13:55 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Jing Huang, James E.J. Bottomley, open list:BROCADE BFA FC SC...,
	kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 467 bytes --]

On Fri, Jul 29, 2011 at 11:53:06AM +0300, Dan Carpenter wrote:
> 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 <error27@gmail.com>

Ping.

regards,
dan carpenter


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [resend] [patch] [SCSI] bfa: dereferencing freed memory in bfad_im_probe()
  2011-07-29  8:53 [patch] [SCSI] bfa: dereferencing freed memory in bfad_im_probe() Dan Carpenter
  2011-11-18 13:55 ` Dan Carpenter
@ 2012-02-29 12:59 ` Dan Carpenter
  1 sibling, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2012-02-29 12:59 UTC (permalink / raw)
  To: Jing Huang
  Cc: James E.J. Bottomley, open list:BROCADE BFA FC SC...,
	linux-kernel, kernel-janitors

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 <error27@gmail.com>
---
I sent this last July and asked about it again in November but I never
heard back.  It still applies fine with 2 lines of fuzz.

diff --git a/drivers/scsi/bfa/bfad_im.c b/drivers/scsi/bfa/bfad_im.c
index 0131238..7f7cca0 100644
--- a/drivers/scsi/bfa/bfad_im.c
+++ b/drivers/scsi/bfa/bfad_im.c
@@ -685,25 +685,21 @@ bfa_status_t
 bfad_im_probe(struct bfad_s *bfad)
 {
 	struct bfad_im_s      *im;
-	bfa_status_t    rc = BFA_STATUS_OK;
 
 	im = kzalloc(sizeof(struct bfad_im_s), GFP_KERNEL);
-	if (im = NULL) {
-		rc = BFA_STATUS_ENOMEM;
-		goto ext;
-	}
+	if (im = NULL)
+		return BFA_STATUS_ENOMEM;
 
 	bfad->im = im;
 	im->bfad = bfad;
 
 	if (bfad_thread_workq(bfad) != BFA_STATUS_OK) {
 		kfree(im);
-		rc = BFA_STATUS_FAILED;
+		return BFA_STATUS_FAILED;
 	}
 
 	INIT_WORK(&im->aen_im_notify_work, bfad_aen_im_notify_handler);
-ext:
-	return rc;
+	return BFA_STATUS_OK;
 }
 
 void

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-02-29 12:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-29  8:53 [patch] [SCSI] bfa: dereferencing freed memory in bfad_im_probe() Dan Carpenter
2011-11-18 13:55 ` Dan Carpenter
2012-02-29 12:59 ` [resend] " Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox