From: Dan Carpenter <error27@gmail.com>
To: Guangshuo Li <lgs201920130244@gmail.com>
Cc: "Markus Elfring" <Markus.Elfring@web.de>,
platform-driver-x86@vger.kernel.org,
"Bao Cheng Su" <baocheng.su@siemens.com>,
"Benedikt Niedermayr" <benedikt.niedermayr@siemens.com>,
"Hans de Goede" <hansg@kernel.org>,
"Henning Schild" <henning.schild@siemens.com>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Tobias Schaffner" <tobias.schaffner@siemens.com>,
stable@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] platform/x86: simatic-ipc: fix platform device leak on registration failure
Date: Tue, 22 Sep 2026 12:51:36 +0300 [thread overview]
Message-ID: <arJPqCrNK-NR41uU@stanley.mountain> (raw)
In-Reply-To: <CANUHTR9+rLuPrd1aifKws++POOKSm+2jxBaJaC1iF5z5x0e13Q@mail.gmail.com>
On Tue, Sep 22, 2026 at 04:13:17PM +0800, Guangshuo Li wrote:
>
> Would it make sense to share the cleanup path and rely on
> platform_device_unregister() handling NULL/ERR_PTR, like this?
>
> +static void unregister_platform_devices(void)
> +{
> + platform_device_unregister(ipc_wdt_platform_device);
> + platform_device_unregister(ipc_led_platform_device);
> + platform_device_unregister(ipc_batt_platform_device);
> +}
Having one magical cleanup function is the most bug prone way to
write cleanup. Use an unwind ladder.
https://staticthinking.wordpress.com/2022/04/28/free-the-last-thing-style/
regards,
dan carpenter
next prev parent reply other threads:[~2026-09-22 9:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-21 7:53 Guangshuo Li
2026-09-21 10:10 ` Markus Elfring
2026-09-22 8:13 ` Guangshuo Li
2026-09-22 9:07 ` Markus Elfring
2026-09-22 9:51 ` Dan Carpenter [this message]
2026-09-21 15:05 ` krzk
2026-09-22 2:38 ` Guangshuo Li
2026-09-21 15:09 ` krzk
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=arJPqCrNK-NR41uU@stanley.mountain \
--to=error27@gmail.com \
--cc=Markus.Elfring@web.de \
--cc=baocheng.su@siemens.com \
--cc=benedikt.niedermayr@siemens.com \
--cc=hansg@kernel.org \
--cc=henning.schild@siemens.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=lgs201920130244@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=tobias.schaffner@siemens.com \
/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®