diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-12-12 00:11:02 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-12-18 18:50:16 -0500 |
commit | ecfbf6fd9c03be7dfe3eafc3846641b9d463607b (patch) | |
tree | c7383b5397df9dbf918f330e57324b3603a0f18d | |
parent | 80b9bbefc345079bddc4959de016ba4074b0c8d6 (diff) |
Driver core: Fix device_add_attrs() error code path
If the addition of dev_attr_online fails, device_add_attrs() should
remove device attribute groups as well as type and class attribute
groups before returning an error code. Make that happen.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Toshi Kani <toshi.kani@hp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/base/core.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c index aab43fbb8336..2b567177ef78 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -491,11 +491,13 @@ static int device_add_attrs(struct device *dev) | |||
491 | if (device_supports_offline(dev) && !dev->offline_disabled) { | 491 | if (device_supports_offline(dev) && !dev->offline_disabled) { |
492 | error = device_create_file(dev, &dev_attr_online); | 492 | error = device_create_file(dev, &dev_attr_online); |
493 | if (error) | 493 | if (error) |
494 | goto err_remove_type_groups; | 494 | goto err_remove_dev_groups; |
495 | } | 495 | } |
496 | 496 | ||
497 | return 0; | 497 | return 0; |
498 | 498 | ||
499 | err_remove_dev_groups: | ||
500 | device_remove_groups(dev, dev->groups); | ||
499 | err_remove_type_groups: | 501 | err_remove_type_groups: |
500 | if (type) | 502 | if (type) |
501 | device_remove_groups(dev, type->groups); | 503 | device_remove_groups(dev, type->groups); |