mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: "Guangshuo Li" <lgs201920130244@gmail.com>,
	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>
Cc: 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: Mon, 21 Sep 2026 12:10:30 +0200	[thread overview]
Message-ID: <cdb67eed-9e75-4310-ae4f-21ca67f20bd2@web.de> (raw)
In-Reply-To: <20260921075312.120983-1-lgs201920130244@gmail.com>

…
> +++ b/drivers/platform/x86/siemens/simatic-ipc.c
> @@ -118,8 +119,11 @@ static int register_platform_devices(u32 station_id)
>  			platform_device_register_data(NULL, pdevname,
>  				PLATFORM_DEVID_NONE, &platform_data,
>  				sizeof(struct simatic_ipc_platform));
> -		if (IS_ERR(ipc_batt_platform_device))
> -			return PTR_ERR(ipc_batt_platform_device);
> +		if (IS_ERR(ipc_batt_platform_device)) {
> +			ret = PTR_ERR(ipc_batt_platform_device);
> +			ipc_batt_platform_device = NULL;
> +			goto err_unregister;
> +		}
…

How do you think about to avoid duplicate checks and variable resets
in such a function implementation?

Regards,
Markus

  reply	other threads:[~2026-09-21 10:16 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 [this message]
2026-09-22  8:13   ` Guangshuo Li
2026-09-22  9:07     ` Markus Elfring
2026-09-22  9:51     ` Dan Carpenter
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=cdb67eed-9e75-4310-ae4f-21ca67f20bd2@web.de \
    --to=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®