linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] sg: set class_data after success
@ 2008-01-15  4:17 FUJITA Tomonori
  2008-01-15  4:54 ` Douglas Gilbert
  0 siblings, 1 reply; 2+ messages in thread
From: FUJITA Tomonori @ 2008-01-15  4:17 UTC (permalink / raw)
  To: dougg; +Cc: James.Bottomley, mdr, linux-scsi, tomof

If cdev_add fails in sg_add, sg_remove crashes since class_data is
bogus.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
---
 drivers/scsi/sg.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index f1871ea..92b4367 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -1418,7 +1418,6 @@ sg_add(struct class_device *cl_dev, struct class_interface *cl_intf)
 		goto out;
 	}
 
-	class_set_devdata(cl_dev, sdp);
 	error = cdev_add(cdev, MKDEV(SCSI_GENERIC_MAJOR, sdp->index), 1);
 	if (error)
 		goto cdev_add_err;
@@ -1447,6 +1446,8 @@ sg_add(struct class_device *cl_dev, struct class_interface *cl_intf)
 		    "Attached scsi generic sg%d type %d\n", sdp->index,
 		    scsidp->type);
 
+	class_set_devdata(cl_dev, sdp);
+
 	return 0;
 
 cdev_add_err:
-- 
1.5.3.4


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

* Re: [PATCH 1/2] sg: set class_data after success
  2008-01-15  4:17 [PATCH 1/2] sg: set class_data after success FUJITA Tomonori
@ 2008-01-15  4:54 ` Douglas Gilbert
  0 siblings, 0 replies; 2+ messages in thread
From: Douglas Gilbert @ 2008-01-15  4:54 UTC (permalink / raw)
  To: FUJITA Tomonori; +Cc: James.Bottomley, mdr, linux-scsi, tomof

FUJITA Tomonori wrote:
> If cdev_add fails in sg_add, sg_remove crashes since class_data is
> bogus.
> 
> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
> ---
>  drivers/scsi/sg.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
> index f1871ea..92b4367 100644
> --- a/drivers/scsi/sg.c
> +++ b/drivers/scsi/sg.c
> @@ -1418,7 +1418,6 @@ sg_add(struct class_device *cl_dev, struct class_interface *cl_intf)
>  		goto out;
>  	}
>  
> -	class_set_devdata(cl_dev, sdp);
>  	error = cdev_add(cdev, MKDEV(SCSI_GENERIC_MAJOR, sdp->index), 1);
>  	if (error)
>  		goto cdev_add_err;
> @@ -1447,6 +1446,8 @@ sg_add(struct class_device *cl_dev, struct class_interface *cl_intf)
>  		    "Attached scsi generic sg%d type %d\n", sdp->index,
>  		    scsidp->type);
>  
> +	class_set_devdata(cl_dev, sdp);
> +
>  	return 0;
>  
>  cdev_add_err:

Tomo,
Thanks.

Signed-off-by: Douglas Gilbert <dougg@torque.net>


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

end of thread, other threads:[~2008-01-15  4:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-15  4:17 [PATCH 1/2] sg: set class_data after success FUJITA Tomonori
2008-01-15  4:54 ` Douglas Gilbert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).