[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAHp75VeT5hH+rfpndW_i1H9nEV5pJyeP=26-oHnJYcq64NE4TQ@mail.gmail.com>
Date: Tue, 5 Feb 2019 18:21:11 +0200
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Aditya Pakki <pakki001@....edu>
Cc: kjlu@....edu, Darren Hart <dvhart@...radead.org>,
Andy Shevchenko <andy@...radead.org>,
Platform Driver <platform-driver-x86@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] platform: x86: Add check for led_classdev_register
On Tue, Dec 25, 2018 at 12:08 AM Aditya Pakki <pakki001@....edu> wrote:
>
> In function alienware_zone_init, the function led_classdev_register
> can return an error on failure. The fix checks the error and frees
> the allocated resources.
>
I'm not sure about this.
Is the LED registration fatal?
> Signed-off-by: Aditya Pakki <pakki001@....edu>
> ---
> drivers/platform/x86/alienware-wmi.c | 13 ++++++++++++-
> 1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/platform/x86/alienware-wmi.c b/drivers/platform/x86/alienware-wmi.c
> index f10af5c383c5..63ab6a2eb613 100644
> --- a/drivers/platform/x86/alienware-wmi.c
> +++ b/drivers/platform/x86/alienware-wmi.c
> @@ -441,6 +441,7 @@ static int alienware_zone_init(struct platform_device *dev)
> u8 zone;
> char buffer[10];
> char *name;
> + int ret;
>
> if (interface == WMAX) {
> lighting_control_state = WMAX_RUNNING;
> @@ -492,7 +493,17 @@ static int alienware_zone_init(struct platform_device *dev)
> zone_attrs[quirks->num_zones] = &dev_attr_lighting_control_state.attr;
> zone_attribute_group.attrs = zone_attrs;
>
> - led_classdev_register(&dev->dev, &global_led);
> + ret = led_classdev_register(&dev->dev, &global_led);
> + if (ret < 0) {
> + if (zone_dev_attrs) {
> + for (zone = 0; zone < quirks->num_zones; zone++)
> + kfree(zone_dev_attrs[zone].attr.name);
> + }
> + kfree(zone_dev_attrs);
> + kfree(zone_data);
> + kfree(zone_attrs);
> + return ret;
> + }
>
> return sysfs_create_group(&dev->dev.kobj, &zone_attribute_group);
> }
> --
> 2.17.1
>
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists