input: touchscreen: Add NULL pointer check before dereference
diff mbox series

Message ID 20190901182309.GA5574@ahmlpt0706
State New
Delegated to: Dmitry Torokhov
Headers show
Series
  • input: touchscreen: Add NULL pointer check before dereference
Related show

Commit Message

Saiyam Doshi Sept. 1, 2019, 6:23 p.m. UTC
In sx8654_probe function, if call to device_get_match_data()
return NULL, it dereferences driver_data from 'id'.

To avoid NULL pointer dereference, add check to make sure
'id' is not NULL.

Signed-off-by: Saiyam Doshi <saiyamdoshi.in@gmail.com>
---
 drivers/input/touchscreen/sx8654.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch
diff mbox series

diff --git a/drivers/input/touchscreen/sx8654.c b/drivers/input/touchscreen/sx8654.c
index de85e57b2486..7121a3d41555 100644
--- a/drivers/input/touchscreen/sx8654.c
+++ b/drivers/input/touchscreen/sx8654.c
@@ -333,7 +333,7 @@  static int sx8654_probe(struct i2c_client *client,
 	dev_dbg(&client->dev, "got GPIO reset pin\n");
 
 	sx8654->data = device_get_match_data(&client->dev);
-	if (!sx8654->data)
+	if (!sx8654->data && id)
 		sx8654->data = (const struct sx865x_data *)id->driver_data;
 	if (!sx8654->data) {
 		dev_err(&client->dev, "invalid or missing device data\n");