[PATCH 1/2] gpib: ines: check CIS register mapping

From: Ruoyu Wang

Date: Sun Jun 07 2026 - 05:35:03 EST


ines_gpib_config() maps the PCMCIA attribute-memory window and then
writes the I/O window base through the returned pointer. If ioremap()
fails, the writeb() dereferences a NULL mapping.

Check the mapping result and unwind the partially configured device
before returning -ENOMEM.

Signed-off-by: Ruoyu Wang <ruoyuw560@xxxxxxxxx>
---
drivers/gpib/ines/ines_gpib.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/drivers/gpib/ines/ines_gpib.c b/drivers/gpib/ines/ines_gpib.c
index c000f647f..0968a247e 100644
--- a/drivers/gpib/ines/ines_gpib.c
+++ b/drivers/gpib/ines/ines_gpib.c
@@ -1145,6 +1145,10 @@ static int ines_gpib_config(struct pcmcia_device *link)
return -ENODEV;
}
virt = ioremap(link->resource[2]->start, resource_size(link->resource[2]));
+ if (!virt) {
+ ines_gpib_release(link);
+ return -ENOMEM;
+ }
writeb((link->resource[2]->start >> 2) & 0xff, virt + 0xf0); // IOWindow base
iounmap(virt);

--
2.51.0