Skip to contentSkip to conversation

power: fix incorrect unregistration in power_supply_create_attrs error path

PATCH In review Andres Salomon 2 participants 2 messages Dec 12, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 power: fix incorrect unregistration in power_supply_create_attrs error path

In power_supply_create_attrs(), we create static attributes as referenced by power_supply_static_attrs[i]. After that, if we fail, we unregister via power_supply_static_attrs[psy->properties[i]]. This is incorrect, as psy->properties has absolutely no bearing on static attribs. This patch fixes it to unregister the correct attrib.

Another line which was unnecessarily line wrapped is also unwrapped.

---
 drivers/power/power_supply_sysfs.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
drivers/power/power_supply_sysfs.c +2 -4
index 0331e82..8efedba 100644
@@ -153,8 +153,7 @@ dynamics_failed:
 			   &power_supply_attrs[psy->properties[j]]);
 statics_failed:
 	while (i--)
-		device_remove_file(psy->dev,
-			   &power_supply_static_attrs[psy->properties[i]]);
+		device_remove_file(psy->dev, &power_supply_static_attrs[i]);
 succeed:
 	return rc;
 }
@@ -164,8 +163,7 @@ void power_supply_remove_attrs(struct power_supply *psy)
 	int i;
 
 	for (i = 0; i < ARRAY_SIZE(power_supply_static_attrs); i++)
-		device_remove_file(psy->dev,
-			    &power_supply_static_attrs[i]);
+		device_remove_file(psy->dev, &power_supply_static_attrs[i]);
 
 	for (i = 0; i < psy->num_properties; i++)
 		device_remove_file(psy->dev,
Signature · 1 line
1.5.3.5
#1 lore raw
Quoted 8 lines · Andres Salomon

In power_supply_create_attrs(), we create static attributes as referenced by power_supply_static_attrs[i]. After that, if we fail, we unregister via power_supply_static_attrs[psy->properties[i]]. This is incorrect, as psy->properties has absolutely no bearing on static attribs. This patch fixes it to unregister the correct attrib.

Another line which was unnecessarily line wrapped is also unwrapped.

Will apply to battery-2.6.git, and will try to push this into 2.6.24.

Much thanks.

Quoted 33 lines
---
 drivers/power/power_supply_sysfs.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
drivers/power/power_supply_sysfs.c +2 -4
index 0331e82..8efedba 100644
@@ -153,8 +153,7 @@ dynamics_failed:
 			   &power_supply_attrs[psy->properties[j]]);
 statics_failed:
 	while (i--)
-		device_remove_file(psy->dev,
-			   &power_supply_static_attrs[psy->properties[i]]);
+		device_remove_file(psy->dev, &power_supply_static_attrs[i]);
 succeed:
 	return rc;
 }
@@ -164,8 +163,7 @@ void power_supply_remove_attrs(struct power_supply *psy)
 	int i;
 
 	for (i = 0; i < ARRAY_SIZE(power_supply_static_attrs); i++)
-		device_remove_file(psy->dev,
-			    &power_supply_static_attrs[i]);
+		device_remove_file(psy->dev, &power_supply_static_attrs[i]);
 
 	for (i = 0; i < psy->num_properties; i++)
 		device_remove_file(psy->dev,
Signature · 1 line
1.5.3.5
Signature · 4 lines
Anton Vorontsov
email: [email protected]
backup email: [email protected]
irc://irc.freenode.net/bd2