From: Haotian Zhang <vulab@iscas.ac.cn>
To: dpenkler@gmail.com, gregkh@linuxfoundation.org
Cc: matchstick@neverthere.org, niharchaithanya@gmail.com,
paul.retourne@orange.fr, linux-staging@lists.linux.dev,
linux-kernel@vger.kernel.org, Haotian Zhang <vulab@iscas.ac.cn>
Subject: [PATCH] staging: gpib: ines: Check the return value of ioremap()
Date: Wed, 26 Nov 2025 09:36:18 +0800 [thread overview]
Message-ID: <20251126013618.1052-1-vulab@iscas.ac.cn> (raw)
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
next reply other threads:[~2025-11-26 1:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-26 1:36 Haotian Zhang [this message]
2025-11-26 13:26 ` Greg KH
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=20251126013618.1052-1-vulab@iscas.ac.cn \
--to=vulab@iscas.ac.cn \
--cc=dpenkler@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=matchstick@neverthere.org \
--cc=niharchaithanya@gmail.com \
--cc=paul.retourne@orange.fr \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®