Skip to content

Commit

Permalink
power: fix incorrect unregistration in power_supply_create_attrs erro…
Browse files Browse the repository at this point in the history
…r 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.

Signed-off-by: Andres Salomon <dilinger@debian.org>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
  • Loading branch information
dilinger authored and enomsg committed Feb 1, 2008
1 parent 8efe444 commit 839dc9f
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions drivers/power/power_supply_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,7 @@ int power_supply_create_attrs(struct power_supply *psy)
&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;
}
Expand All @@ -166,8 +165,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,
Expand Down

0 comments on commit 839dc9f

Please sign in to comment.