Răsfoiți Sursa

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.

Signed-off-by: Andres Salomon <dilinger@debian.org>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Andres Salomon 17 ani în urmă
părinte
comite
839dc9f105
1 a modificat fișierele cu 2 adăugiri și 4 ștergeri
  1. 2 4
      drivers/power/power_supply_sysfs.c

+ 2 - 4
drivers/power/power_supply_sysfs.c

@@ -155,8 +155,7 @@ dynamics_failed:
 			   &power_supply_attrs[psy->properties[j]]);
 			   &power_supply_attrs[psy->properties[j]]);
 statics_failed:
 statics_failed:
 	while (i--)
 	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:
 succeed:
 	return rc;
 	return rc;
 }
 }
@@ -166,8 +165,7 @@ void power_supply_remove_attrs(struct power_supply *psy)
 	int i;
 	int i;
 
 
 	for (i = 0; i < ARRAY_SIZE(power_supply_static_attrs); 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++)
 	for (i = 0; i < psy->num_properties; i++)
 		device_remove_file(psy->dev,
 		device_remove_file(psy->dev,