* [PATCH] staging: gpib: ines: Check the return value of ioremap()
@ 2025-11-26 1:36 Haotian Zhang
2025-11-26 13:26 ` Greg KH
0 siblings, 1 reply; 2+ messages in thread
From: Haotian Zhang @ 2025-11-26 1:36 UTC (permalink / raw)
To: dpenkler, gregkh
Cc: matchstick, niharchaithanya, paul.retourne, linux-staging,
linux-kernel, Haotian Zhang
The function ioremap() in ines_gpib_config() 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: bb1bd92fa0f2 ("staging: gpib: Add ines GPIB driver")
Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
---
drivers/staging/gpib/ines/ines_gpib.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/staging/gpib/ines/ines_gpib.c b/drivers/staging/gpib/ines/ines_gpib.c
index c851fd014f48..362a6310cab1 100644
--- a/drivers/staging/gpib/ines/ines_gpib.c
+++ b/drivers/staging/gpib/ines/ines_gpib.c
@@ -1144,6 +1144,11 @@ static int ines_gpib_config(struct pcmcia_device *link)
return -ENODEV;
}
virt = ioremap(link->resource[2]->start, resource_size(link->resource[2]));
+ if (!virt) {
+ dev_warn(&link->dev, "ioremap failed\n");
+ ines_gpib_release(link);
+ return -ENOMEM;
+ }
writeb((link->resource[2]->start >> 2) & 0xff, virt + 0xf0); // IOWindow base
iounmap(virt);
--
2.50.1.windows.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] staging: gpib: ines: Check the return value of ioremap()
2025-11-26 1:36 [PATCH] staging: gpib: ines: Check the return value of ioremap() Haotian Zhang
@ 2025-11-26 13:26 ` Greg KH
0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2025-11-26 13:26 UTC (permalink / raw)
To: Haotian Zhang
Cc: dpenkler, matchstick, niharchaithanya, paul.retourne,
linux-staging, linux-kernel
On Wed, Nov 26, 2025 at 09:36:18AM +0800, Haotian Zhang wrote:
> The function ioremap() in ines_gpib_config() 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: bb1bd92fa0f2 ("staging: gpib: Add ines GPIB driver")
> Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
> ---
> drivers/staging/gpib/ines/ines_gpib.c | 5 +++++
This file has now moved :(
And do you have this hardware to test this with? If so, a lot more
cleanup can be done in this function.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-11-26 13:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-26 1:36 [PATCH] staging: gpib: ines: Check the return value of ioremap() Haotian Zhang
2025-11-26 13:26 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).