Commit ad8e43cf authored by Maurizio Lombardi's avatar Maurizio Lombardi Committed by Greg Kroah-Hartman

scsi: ses: do not add a device to an enclosure if enclosure_add_links() fails.

commit 62e62ffd upstream.

The enclosure_add_device() function should fail if it can't create the
relevant sysfs links.
Signed-off-by: default avatarMaurizio Lombardi <mlombard@redhat.com>
Tested-by: default avatarDouglas Miller <dougmill@linux.vnet.ibm.com>
Acked-by: default avatarJames Bottomley <jejb@linux.vnet.ibm.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent adc01577
......@@ -375,6 +375,7 @@ int enclosure_add_device(struct enclosure_device *edev, int component,
struct device *dev)
{
struct enclosure_component *cdev;
int err;
if (!edev || component >= edev->components)
return -EINVAL;
......@@ -384,12 +385,17 @@ int enclosure_add_device(struct enclosure_device *edev, int component,
if (cdev->dev == dev)
return -EEXIST;
if (cdev->dev)
if (cdev->dev) {
enclosure_remove_links(cdev);
put_device(cdev->dev);
put_device(cdev->dev);
}
cdev->dev = get_device(dev);
return enclosure_add_links(cdev);
err = enclosure_add_links(cdev);
if (err) {
put_device(cdev->dev);
cdev->dev = NULL;
}
return err;
}
EXPORT_SYMBOL_GPL(enclosure_add_device);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment