Driver core: Fix device_add_attrs() error code path
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
@@ -491,11 +491,13 @@ static int device_add_attrs(struct devicif (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);
Quoted 7 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
If the addition of
dev_attr_onlinefails,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 <[email protected]>
Nice catch!
-Toshi
Greg Kroah-Hartman
maintainerQuoted 7 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
If the addition of
dev_attr_onlinefails,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 <[email protected]>
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
Quoted 11 lines · Greg Kroah-Hartman
Quoted 7 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
If the addition of
dev_attr_onlinefails,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 <[email protected]>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