mirror of
https://github.com/torvalds/linux.git
synced 2026-11-27 17:02:17 +00:00
scsi: sd: Free scsi_disk device via put_device()
After a device is initialized via device_initialize() it should be freed via put_device(). sd_probe() currently gets this wrong, fix it up. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Bart Van Assche <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Ming Lei <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
This commit is contained in:
committed by
Martin K. Petersen
parent
e4953a9310
commit
265dfe8ebb
+5
-4
@@ -3401,15 +3401,16 @@ static int sd_probe(struct device *dev)
|
||||
}
|
||||
|
||||
device_initialize(&sdkp->dev);
|
||||
sdkp->dev.parent = dev;
|
||||
sdkp->dev.parent = get_device(dev);
|
||||
sdkp->dev.class = &sd_disk_class;
|
||||
dev_set_name(&sdkp->dev, "%s", dev_name(dev));
|
||||
|
||||
error = device_add(&sdkp->dev);
|
||||
if (error)
|
||||
goto out_free_index;
|
||||
if (error) {
|
||||
put_device(&sdkp->dev);
|
||||
goto out;
|
||||
}
|
||||
|
||||
get_device(dev);
|
||||
dev_set_drvdata(dev, sdkp);
|
||||
|
||||
gd->major = sd_major((index & 0xf0) >> 4);
|
||||
|
||||
Reference in New Issue
Block a user