From: Mario Limonciello <mario.limonciello@amd.com>
To: Kurt Borja <kuurtb@gmail.com>
Cc: Dell.Client.Kernel@dell.com, hdegoede@redhat.com,
ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org,
platform-driver-x86@vger.kernel.org, w_armin@gmx.de
Subject: Re: [PATCH 4/5] alienware-wmi: Fix module init error handling
Date: Tue, 19 Nov 2024 10:06:48 -0600 [thread overview]
Message-ID: <e02d8687-b5b8-4970-8bd9-ad3ad9549fc0@amd.com> (raw)
In-Reply-To: <20241119043523.25650-1-kuurtb@gmail.com>
On 11/18/2024 22:35, Kurt Borja wrote:
> Propagate led_classdev_register return value in case of error.
> Call led_classdev_unregister in case sysfs_create_group fails.
>
> If alienware_zone_init fails, alienware_zone_exit should not be called
> because the latter unregisters/removes the led class and the sysfs
> group, which may not be registered/created if the former failed
> prematurely.
>
> Signed-off-by: Kurt Borja <kuurtb@gmail.com>
> ---
> drivers/platform/x86/dell/alienware-wmi.c | 16 +++++++++++++---
> 1 file changed, 13 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c
> index 980ffc545093..44f1f7b57d0a 100644
> --- a/drivers/platform/x86/dell/alienware-wmi.c
> +++ b/drivers/platform/x86/dell/alienware-wmi.c
> @@ -628,6 +628,7 @@ static int alienware_zone_init(struct platform_device *pdev)
> char *name;
> struct device_attribute *zone_dev_attrs;
> struct attribute **zone_attrs;
> + int ret;
>
> if (interface == WMAX) {
> lighting_control_state = WMAX_RUNNING;
> @@ -675,9 +676,19 @@ static int alienware_zone_init(struct platform_device *pdev)
> zone_attrs[quirks->num_zones] = &dev_attr_lighting_control_state.attr;
> zone_attribute_group.attrs = zone_attrs;
>
> - led_classdev_register(&pdev->dev, &global_led);
> + ret = led_classdev_register(&pdev->dev, &global_led);
How about switching to the devm version of led_classdev_register instead
so you can keep a simpler cleanup?
> + if (ret < 0)
> + return ret;
> +
> + ret = sysfs_create_group(&pdev->dev.kobj, &zone_attribute_group);
> + if (ret < 0)
> + goto fail_prep_zone_group;
> +
> + return 0;
>
> - return sysfs_create_group(&pdev->dev.kobj, &zone_attribute_group);
> +fail_prep_zone_group:
> + led_classdev_unregister(&global_led);
> + return ret;
> }
>
> static void alienware_zone_exit(struct platform_device *dev)
> @@ -1223,7 +1234,6 @@ static int __init alienware_wmi_init(void)
> return 0;
>
> fail_prep_zones:
> - alienware_zone_exit(platform_device);
> remove_thermal_profile();
> fail_prep_thermal_profile:
> fail_prep_deepsleep:
next prev parent reply other threads:[~2024-11-19 16:06 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-19 4:35 Kurt Borja
2024-11-19 14:55 ` Markus Elfring
2024-11-19 16:06 ` Kurt Borja
2024-11-19 16:22 ` Ilpo Järvinen
2024-11-19 19:01 ` Kurt Borja
2024-11-19 16:06 ` Mario Limonciello [this message]
2024-11-19 16:11 ` Kurt Borja
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e02d8687-b5b8-4970-8bd9-ad3ad9549fc0@amd.com \
--to=mario.limonciello@amd.com \
--cc=Dell.Client.Kernel@dell.com \
--cc=hdegoede@redhat.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=kuurtb@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=w_armin@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®