summaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorBanajit Goswami <bgoswami@codeaurora.org>2018-08-28 06:15:39 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-09-16 22:37:16 +0200
commitbdae566d5d9733b6e32b378668b84eadf28a94d4 (patch)
tree76e8b4c1207fc580c76d62c08f6bde9e139fe863 /drivers/base
parentdrivers/base/devtmpfs.c: don't pretend path is const in delete_path (diff)
downloadlinux-bdae566d5d9733b6e32b378668b84eadf28a94d4.tar.xz
linux-bdae566d5d9733b6e32b378668b84eadf28a94d4.zip
component: fix loop condition to call unbind() if bind() fails
During component_bind_all(), if bind() fails for any particular component associated with a master, unbind() should be called for all previous components in that master's match array, whose bind() might have completed successfully. As per the current logic, if bind() fails for the component at position 'n' in the master's match array, it would start calling unbind() from component in 'n'th position itself and work backwards, and will always skip calling unbind() for component in 0th position in the master's match array. Fix this by updating the loop condition, and the logic to refer to the components in master's match array, so that unbind() is called for all components starting from 'n-1'st position in the array, until (and including) component in 0th position. Signed-off-by: Banajit Goswami <bgoswami@codeaurora.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/component.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/base/component.c b/drivers/base/component.c
index 8946dfee4768..e8d676fad0c9 100644
--- a/drivers/base/component.c
+++ b/drivers/base/component.c
@@ -536,9 +536,9 @@ int component_bind_all(struct device *master_dev, void *data)
}
if (ret != 0) {
- for (; i--; )
- if (!master->match->compare[i].duplicate) {
- c = master->match->compare[i].component;
+ for (; i > 0; i--)
+ if (!master->match->compare[i - 1].duplicate) {
+ c = master->match->compare[i - 1].component;
component_unbind(c, master, data);
}
}