From: Link Mauve <kernel@linkmauve.fr>
To: Haotian Zhang <vulab@iscas.ac.cn>
Cc: alexandre.belloni@bootlin.com, linkmauve@linkmauve.fr,
linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] rtc: gamecube: Check the return value of ioremap()
Date: Wed, 26 Nov 2025 09:14:50 +0100 [thread overview]
Message-ID: <aSa2-nczGtaVihYE@desktop> (raw)
In-Reply-To: <20251126080625.1752-1-vulab@iscas.ac.cn>
[-- Attachment #1: Type: text/plain, Size: 1369 bytes --]
Hi,
On Wed, Nov 26, 2025 at 04:06:25PM +0800, Haotian Zhang wrote:
> The function ioremap() in gamecube_rtc_read_offset_from_sram() can fail
> and return NULL, which is dereferenced without checking, leading to a
> NULL pointer dereference.
>
> Add a check for the return value of ioremap() and return -ENOMEM on
> failure.
>
> Fixes: 86559400b3ef ("rtc: gamecube: Add a RTC driver for the GameCube, Wii and Wii U")
> Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
You forgot to carry my R-b, but here it is again:
Reviewed-by: Link Mauve <kernel@linkmauve.fr>
> ---
> Changes in v2:
> -Use lowercase for error message to match existing style.
> ---
> drivers/rtc/rtc-gamecube.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/rtc/rtc-gamecube.c b/drivers/rtc/rtc-gamecube.c
> index c828bc8e05b9..045d5d45ab4b 100644
> --- a/drivers/rtc/rtc-gamecube.c
> +++ b/drivers/rtc/rtc-gamecube.c
> @@ -242,6 +242,10 @@ static int gamecube_rtc_read_offset_from_sram(struct priv *d)
> }
>
> hw_srnprot = ioremap(res.start, resource_size(&res));
> + if (!hw_srnprot) {
> + pr_err("failed to ioremap hw_srnprot\n");
> + return -ENOMEM;
> + }
> old = ioread32be(hw_srnprot);
>
> /* TODO: figure out why we use this magic constant. I obtained it by
> --
> 2.50.1.windows.1
>
--
Link Mauve
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2025-11-26 8:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-26 1:20 [PATCH] rtc: gamecube: Check the return value of ioremap() Haotian Zhang
2025-11-26 7:33 ` Link Mauve
2025-11-26 8:06 ` [PATCH v2] " Haotian Zhang
2025-11-26 8:14 ` Link Mauve [this message]
2025-12-08 22:10 ` Alexandre Belloni
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=aSa2-nczGtaVihYE@desktop \
--to=kernel@linkmauve.fr \
--cc=alexandre.belloni@bootlin.com \
--cc=linkmauve@linkmauve.fr \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rtc@vger.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.