Skip to contentSkip to conversation

Driver core: Fix device_add_attrs() error code path

PATCH In review Rafael J. Wysocki 3 participants 4 messages Dec 12, 2013 – Dec 13, 2013 Driver core

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Driver core: Fix device_add_attrs() error code path

From: Rafael J. Wysocki <[email protected]>

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.

---
 drivers/base/core.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/base/core.c +3 -1
Index: linux-pm/drivers/base/core.c
===================================================================
@@ -491,11 +491,13 @@ static int device_add_attrs(struct devic
 	if (device_supports_offline(dev) && !dev->offline_disabled) {
 		error = device_create_file(dev, &dev_attr_online);
 		if (error)
-			goto err_remove_type_groups;
+			goto err_remove_dev_groups;
 	}
 
 	return 0;
 
+ err_remove_dev_groups:
+ 	device_remove_groups(dev, dev->groups);
  err_remove_type_groups:
 	if (type)
 		device_remove_groups(dev, type->groups);
#2 lore raw
In reply to Rafael J. Wysocki
Quoted 7 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

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.

Does this need tob e in 3.13-final? Or can it wait for 3.14-rc1? The odds that this file creation would ever fail is _really_ low, right?

thanks,

greg k-h

#3 lore raw
Quoted 11 lines · Greg Kroah-Hartman
Quoted 7 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

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.

Does this need tob e in 3.13-final? Or can it wait for 3.14-rc1? The odds that this file creation would ever fail is _really_ low, right?

Yeah, it's more of a cleanup than a fix, so 3.14-rc1 should be fine.

Thanks,
Rafael