* [PATCH] nvmem: nintendo-otp: Fix potential NULL pointer dereference in nintendo_otp_probe()
@ 2025-12-10 3:38 Haotian Zhang
2025-12-11 13:37 ` Link Mauve
2026-01-05 7:59 ` Srinivas Kandagatla
0 siblings, 2 replies; 3+ messages in thread
From: Haotian Zhang @ 2025-12-10 3:38 UTC (permalink / raw)
To: srini; +Cc: linkmauve, linux-kernel, Haotian Zhang
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
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] nvmem: nintendo-otp: Fix potential NULL pointer dereference in nintendo_otp_probe()
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
2026-01-05 7:59 ` Srinivas Kandagatla
1 sibling, 0 replies; 3+ messages in thread
From: Link Mauve @ 2025-12-11 13:37 UTC (permalink / raw)
To: Haotian Zhang; +Cc: srini, linkmauve, linux-kernel
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
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] nvmem: nintendo-otp: Fix potential NULL pointer dereference in nintendo_otp_probe()
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
@ 2026-01-05 7:59 ` Srinivas Kandagatla
1 sibling, 0 replies; 3+ messages in thread
From: Srinivas Kandagatla @ 2026-01-05 7:59 UTC (permalink / raw)
To: Haotian Zhang, srini; +Cc: linkmauve, linux-kernel
On 12/10/25 3:38 AM, Haotian Zhang wrote:
> of_match_device() may return NULL if no match is found.
> Dereferencing the return value of_id in nintendo_otp_probe()
This does not make sense, nintendo_otp_probe() will never be called
without a dt compatible match.
Why do you think this will be null?
--srini
> 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;
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-01-05 7:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2026-01-05 7:59 ` Srinivas Kandagatla
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox