diff options
author | Alex Shi <alex.shi@linaro.org> | 2017-07-28 04:01:58 (GMT) |
---|---|---|
committer | Alex Shi <alex.shi@linaro.org> | 2017-07-28 04:01:58 (GMT) |
commit | dadf6cd391f4208cfe0fbb01ba5b70c0f1b3b920 (patch) | |
tree | 5339918e23c6b8bca68b6b9cb10f5ab5e5cfbea2 /drivers/misc/enclosure.c | |
parent | 97baec00952afead33eea0b1b97ee4d5850dce00 (diff) | |
parent | efcfbfb1d8bf756d1b58fe215bf4e419d176435b (diff) | |
download | linux-dadf6cd391f4208cfe0fbb01ba5b70c0f1b3b920.tar.xz |
Merge tag 'v4.9.40' into linux-linaro-lsk-v4.9
This is the 4.9.40 stable release
Diffstat (limited to 'drivers/misc/enclosure.c')
-rw-r--r-- | drivers/misc/enclosure.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c index 65fed71..cc91f7b 100644 --- a/drivers/misc/enclosure.c +++ b/drivers/misc/enclosure.c @@ -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); |