public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Danilo Krummrich" <dakr@kernel.org>
To: "Guangshuo Li" <lgs201920130244@gmail.com>
Cc: "Luis Chamberlain" <mcgrof@kernel.org>,
	"Russ Weight" <russ.weight@linux.dev>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	"Tianfei zhang" <tianfei.zhang@intel.com>,
	<driver-core@lists.linux.dev>, <linux-kernel@vger.kernel.org>,
	<stable@vger.kernel.org>
Subject: Re: [PATCH v2] firmware_loader: fix device reference leak in firmware_upload_register()
Date: Mon, 04 May 2026 21:18:16 +0200	[thread overview]
Message-ID: <DIA4URMZOEAU.1146WQ3M1DO7M@kernel.org> (raw)
In-Reply-To: <20260418070220.64542-1-lgs201920130244@gmail.com>

On Sat Apr 18, 2026 at 9:02 AM CEST, Guangshuo Li wrote:
> diff --git a/drivers/base/firmware_loader/sysfs_upload.c b/drivers/base/firmware_loader/sysfs_upload.c
> index f59a7856934c..a6dab34b22d8 100644
> --- a/drivers/base/firmware_loader/sysfs_upload.c
> +++ b/drivers/base/firmware_loader/sysfs_upload.c
> @@ -351,7 +351,8 @@ firmware_upload_register(struct module *module, struct device *parent,
>  	if (ret != 0) {
>  		if (ret > 0)
>  			ret = -EINVAL;
> -		goto free_fw_sysfs;
> +		put_device(fw_dev);
> +		goto exit_module_put;
>  	}
>  	fw_priv->is_paged_buf = true;
>  	fw_sysfs->fw_priv = fw_priv;

I think this assignment comes too late, by calling put_device() we eventually
end up in fw_upload_free() which expects this to be assigned already.

I didn't think it through entirely, but can we just move the

	fw_sysfs->fw_upload_priv = fw_upload_priv;

assignment to after alloc_lookup_fw_priv(), so fw_dev_release() does not enter
this path in the first place?

  parent reply	other threads:[~2026-05-04 19:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-18  7:02 [PATCH v2] firmware_loader: fix device reference leak in firmware_upload_register() Guangshuo Li
2026-05-04 15:16 ` Russ Weight
2026-05-04 19:18 ` Danilo Krummrich [this message]
2026-05-05  8:48   ` Guangshuo Li

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=DIA4URMZOEAU.1146WQ3M1DO7M@kernel.org \
    --to=dakr@kernel.org \
    --cc=driver-core@lists.linux.dev \
    --cc=gregkh@linuxfoundation.org \
    --cc=lgs201920130244@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=rafael@kernel.org \
    --cc=russ.weight@linux.dev \
    --cc=stable@vger.kernel.org \
    --cc=tianfei.zhang@intel.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