[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAJZ5v0hi=Hh5RL0whSTxD7Gd+59R44v7B5bQv0JThw6i93L-Zw@mail.gmail.com>
Date: Wed, 18 Dec 2024 14:59:53 +0100
From: "Rafael J. Wysocki" <rafael@...nel.org>
To: Ma Ke <make_ruc2021@....com>
Cc: rafael@...nel.org, linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] powercap: Check dev_set_name() return value
On Wed, Dec 11, 2024 at 3:07 AM Ma Ke <make_ruc2021@....com> wrote:
>
> 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@....com>
> ---
> drivers/powercap/powercap_sys.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> 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;
> +
Why is it necessary to fail in this case?
> result = device_register(&power_zone->dev);
> if (result) {
> put_device(&power_zone->dev);
> --
Powered by blists - more mailing lists