Thread (7 messages) 7 messages, 3 authors, 2019-11-18
STALE2386d

[PATCH] Input: synaptics-rmi4 - validate that the rmi_dev pointer is set before dereferencing it

From: Andrew Duggan <hidden>
Date: 2019-10-23 01:24:10
Also in: lkml
Subsystem: input (keyboard, mouse, joystick, touchscreen) drivers, the rest · Maintainers: Dmitry Torokhov, Linus Torvalds

A bug in hid-rmi was causing rmi_unregister_transport_device() to be
called even if the call to rmi_register_transport_device() failed to
allocate the rmi device. A patch has been submitted to fix the issue in
hid-rmi. This patch will ensure that should a simialr situation
occur then the rmi driver will not dereference a NULL pointer.

Signed-off-by: Andrew Duggan <redacted>
---
 drivers/input/rmi4/rmi_bus.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/input/rmi4/rmi_bus.c b/drivers/input/rmi4/rmi_bus.c
index af706a583656..6c3abae1e159 100644
--- a/drivers/input/rmi4/rmi_bus.c
+++ b/drivers/input/rmi4/rmi_bus.c
@@ -118,8 +118,10 @@ void rmi_unregister_transport_device(struct rmi_transport_dev *xport)
 {
 	struct rmi_device *rmi_dev = xport->rmi_dev;
 
-	device_del(&rmi_dev->dev);
-	put_device(&rmi_dev->dev);
+	if (rmi_dev) {
+		device_del(&rmi_dev->dev);
+		put_device(&rmi_dev->dev);
+	}
 }
 EXPORT_SYMBOL(rmi_unregister_transport_device);
 
-- 
2.20.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help