Skip to contentSkip to conversation

Input: check the return value of ioremap() in gscps2_probe()

PATCH Applied [email protected] 2 participants 2 messages Aug 2, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Input: check the return value of ioremap() in gscps2_probe()

From: Xie Shaowen <[email protected]>

The function ioremap() in gscps2_probe() can fail, so its return value should be checked.

Fixes 4bdc0d676a643 ("remove ioremap_nocache and devm_ioremap_nocache")
---
 drivers/input/serio/gscps2.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/input/serio/gscps2.c +4 -0
index a9065c6ab550..da2c67cb8642 100644
@@ -350,6 +350,10 @@ static int __init gscps2_probe(struct parisc_device *dev)
 	ps2port->port = serio;
 	ps2port->padev = dev;
 	ps2port->addr = ioremap(hpa, GSC_STATUS + 4);
+	if (!ps2port->addr) {
+		ret = -ENOMEM;
+		goto fail_nomem;
+	}
 	spin_lock_init(&ps2port->lock);
 
 	gscps2_reset(ps2port);
Signature · 1 line
2.25.1
maintainer Applied
#1 lore raw
Quoted 8 lines · On 8/2/22 09:20, [email protected] wrote:

From: Xie Shaowen <[email protected]>

The function ioremap() in gscps2_probe() can fail, so its return value should be checked.

Fixes 4bdc0d676a643 ("remove ioremap_nocache and devm_ioremap_nocache")

I've applied it to the parisc git tree.

Thanks!
Helge

Quoted 19 lines
---
 drivers/input/serio/gscps2.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/input/serio/gscps2.c +4 -0
index a9065c6ab550..da2c67cb8642 100644
@@ -350,6 +350,10 @@ static int __init gscps2_probe(struct parisc_device *dev)
 	ps2port->port = serio;
 	ps2port->padev = dev;
 	ps2port->addr = ioremap(hpa, GSC_STATUS + 4);
+	if (!ps2port->addr) {
+		ret = -ENOMEM;
+		goto fail_nomem;
+	}
 	spin_lock_init(&ps2port->lock);
 
 	gscps2_reset(ps2port);