Message ID | 20241211020645.2123881-1-make_ruc2021@163.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | powercap: Check dev_set_name() return value | expand |
diff --git a/drivers/powercap/powercap_sys.c b/drivers/powercap/powercap_sys.c index 52c32dcbf7d8..11db93b10aa5 100644 --- a/drivers/powercap/powercap_sys.c +++ b/drivers/powercap/powercap_sys.c @@ -552,9 +552,12 @@ struct powercap_zone *powercap_register_zone( power_zone->dev_attr_groups[0] = &power_zone->dev_zone_attr_group; power_zone->dev_attr_groups[1] = NULL; power_zone->dev.groups = power_zone->dev_attr_groups; - dev_set_name(&power_zone->dev, "%s:%x", + result = dev_set_name(&power_zone->dev, "%s:%x", dev_name(power_zone->dev.parent), power_zone->id); + if (result) + goto err_dev_ret; + result = device_register(&power_zone->dev); if (result) { put_device(&power_zone->dev);
It's possible that dev_set_name() returns -ENOMEM. We could catch and handle it by adding dev_set_name() return value check. Signed-off-by: Ma Ke <make_ruc2021@163.com> --- drivers/powercap/powercap_sys.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)