Skip to content

Commit d1220e4

Browse files
ISCAS-Vulabalexandrebelloni
authored andcommitted
rtc: gamecube: Check the return value of ioremap()
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: 8655940 ("rtc: gamecube: Add a RTC driver for the GameCube, Wii and Wii U") Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn> Reviewed-by: Link Mauve <kernel@linkmauve.fr> Link: https://patch.msgid.link/20251126080625.1752-1-vulab@iscas.ac.cn Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
1 parent 22a6db4 commit d1220e4

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

drivers/rtc/rtc-gamecube.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,10 @@ static int gamecube_rtc_read_offset_from_sram(struct priv *d)
242242
}
243243

244244
hw_srnprot = ioremap(res.start, resource_size(&res));
245+
if (!hw_srnprot) {
246+
pr_err("failed to ioremap hw_srnprot\n");
247+
return -ENOMEM;
248+
}
245249
old = ioread32be(hw_srnprot);
246250

247251
/* TODO: figure out why we use this magic constant. I obtained it by

0 commit comments

Comments
 (0)