From: Link Mauve <linkmauve@linkmauve.fr>
To: Haotian Zhang <vulab@iscas.ac.cn>
Cc: srini@kernel.org, linkmauve@linkmauve.fr, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] nvmem: nintendo-otp: Fix potential NULL pointer dereference in nintendo_otp_probe()
Date: Thu, 11 Dec 2025 14:37:54 +0100 [thread overview]
Message-ID: <aTrJMi7q_DX4K8_c@luna> (raw)
In-Reply-To: <20251210033803.1720-1-vulab@iscas.ac.cn>
Hi,
On Wed, Dec 10, 2025 at 11:38:03AM +0800, Haotian Zhang wrote:
> of_match_device() may return NULL if no match is found.
> Dereferencing the return value of_id in nintendo_otp_probe()
> without a check could lead to a NULL pointer dereference.
>
> Add a check for of_id and return -ENODEV upon failure.
>
> Fixes: 3683b761fe3a ("nvmem: nintendo-otp: Add new driver for the Wii and Wii U OTP")
> Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
> ---
> drivers/nvmem/nintendo-otp.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/nvmem/nintendo-otp.c b/drivers/nvmem/nintendo-otp.c
> index 355e7f1fc6d5..89b15a58bf88 100644
> --- a/drivers/nvmem/nintendo-otp.c
> +++ b/drivers/nvmem/nintendo-otp.c
> @@ -87,6 +87,9 @@ static int nintendo_otp_probe(struct platform_device *pdev)
> .root_only = true,
> };
>
> + if (!of_id)
> + return -ENODEV;
> +
> priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
> if (!priv)
> return -ENOMEM;
> --
> 2.50.1.windows.1
>
Thank you for that, this patch is:
Reviewed-by: Link Mauve <kernel@linkmauve.fr>
--
Link Mauve
next prev parent reply other threads:[~2025-12-11 13:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-10 3:38 [PATCH] nvmem: nintendo-otp: Fix potential NULL pointer dereference in nintendo_otp_probe() Haotian Zhang
2025-12-11 13:37 ` Link Mauve [this message]
2026-01-05 7:59 ` Srinivas Kandagatla
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=aTrJMi7q_DX4K8_c@luna \
--to=linkmauve@linkmauve.fr \
--cc=linux-kernel@vger.kernel.org \
--cc=srini@kernel.org \
--cc=vulab@iscas.ac.cn \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.