Message ID | 1513069072-32514-3-git-send-email-hare@suse.de (mailing list archive) |
---|---|
State | Changes Requested |
Headers | show |
On Tue, 2017-12-12 at 09:57 +0100, Hannes Reinecke wrote: > diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c > index ab75ebd..228b0b62 100644 > --- a/drivers/scsi/sd.c > +++ b/drivers/scsi/sd.c > @@ -3399,6 +3399,10 @@ static int sd_probe(struct device *dev) > } > > device_initialize(&sdkp->dev); > + > + if (!get_device(dev)) > + goto out_free_index; get_device(dev) returns the value of the 'dev' argument. Are you sure the if-test is useful? Did you perhaps want to check sdp->sdev_state like scsi_device_get() does? > sdkp->dev.parent = dev; > sdkp->dev.class = &sd_disk_class; > dev_set_name(&sdkp->dev, "%s", dev_name(dev)); > @@ -3407,7 +3411,6 @@ static int sd_probe(struct device *dev) > if (error) > goto out_free_index; > > - get_device(dev); > dev_set_drvdata(dev, sdkp); > > get_device(&sdkp->dev); /* prevent release before async_schedule */ Since the get_device() call has been moved up, are there any error paths that have to be adjusted? Bart.
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index ab75ebd..228b0b62 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -3399,6 +3399,10 @@ static int sd_probe(struct device *dev) } device_initialize(&sdkp->dev); + + if (!get_device(dev)) + goto out_free_index; + sdkp->dev.parent = dev; sdkp->dev.class = &sd_disk_class; dev_set_name(&sdkp->dev, "%s", dev_name(dev)); @@ -3407,7 +3411,6 @@ static int sd_probe(struct device *dev) if (error) goto out_free_index; - get_device(dev); dev_set_drvdata(dev, sdkp); get_device(&sdkp->dev); /* prevent release before async_schedule */
When a new SCSI disk is created we should be checking if the parent device is actually present before proceeding with probing. Signed-off-by: Hannes Reinecke <hare@suse.com> --- drivers/scsi/sd.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)