提交 839dc9f1 编写于 作者: A Andres Salomon 提交者: Anton Vorontsov

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: NAndres Salomon <dilinger@debian.org>
Signed-off-by: NDavid Woodhouse <dwmw2@infradead.org>
上级 8efe4440
......@@ -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;
}
......@@ -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,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册