From: "Danilo Krummrich" <dakr@kernel.org>
To: "Abhishek Kumar" <abhishek_sts8@yahoo.com>
Cc: <mcgrof@kernel.org>, <russ.weight@linux.dev>,
<gregkh@linuxfoundation.org>, <rafael@kernel.org>,
<driver-core@lists.linux.dev>
Subject: Re: [PATCH] firmware_loader: Add null pointer checks in request_firmware_nowait()
Date: Sat, 28 Feb 2026 14:28:04 +0100 [thread overview]
Message-ID: <DGQMP7W3393B.21EXJDERDYSZ5@kernel.org> (raw)
In-Reply-To: <20260228061136.6472-1-abhishek_sts8@yahoo.com>
On Sat Feb 28, 2026 at 7:11 AM CET, Abhishek Kumar wrote:
> diff --git a/drivers/base/firmware_loader/main.c b/drivers/base/firmware_loader/main.c
> index a11b30dda23b..3395ba3d9066 100644
> --- a/drivers/base/firmware_loader/main.c
> +++ b/drivers/base/firmware_loader/main.c
> @@ -1150,7 +1150,8 @@ static void request_firmware_work_func(struct work_struct *work)
> _request_firmware(&fw, fw_work->name, fw_work->device, NULL, 0, 0,
> fw_work->opt_flags);
> fw_work->cont(fw, fw_work->context);
> - put_device(fw_work->device); /* taken in request_firmware_nowait() */
> + if (fw_work->device)
> + put_device(fw_work->device); /* taken in request_firmware_nowait() */
>
> module_put(fw_work->module);
> kfree_const(fw_work->name);
> @@ -1194,7 +1195,8 @@ static int _request_firmware_nowait(
> return -EFAULT;
> }
>
> - get_device(fw_work->device);
> + if (device)
> + get_device(device);
> INIT_WORK(&fw_work->work, request_firmware_work_func);
> schedule_work(&fw_work->work);
> return 0;
Those can only ever be NULL if either request_firmware_nowait() or
firmware_request_nowait_nowarn() are called with NULL and it is up to the user
of those functions to call them with valid arguments.
Besides that, it would just move the bug elsewhere, as _request_firmware()
heavily uses the device pointer.
(Also note that a NULL check by itself doesn't do a lot in terms of robustness,
since a non-null pointer can still be invalid.)
prev parent reply other threads:[~2026-02-28 13:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260228061136.6472-1-abhishek_sts8.ref@yahoo.com>
2026-02-28 6:11 ` [PATCH] firmware_loader: Add null pointer checks in request_firmware_nowait() Abhishek Kumar
2026-02-28 13:28 ` Danilo Krummrich [this message]
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=DGQMP7W3393B.21EXJDERDYSZ5@kernel.org \
--to=dakr@kernel.org \
--cc=abhishek_sts8@yahoo.com \
--cc=driver-core@lists.linux.dev \
--cc=gregkh@linuxfoundation.org \
--cc=mcgrof@kernel.org \
--cc=rafael@kernel.org \
--cc=russ.weight@linux.dev \
/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