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@xxxxxxxxx> --- drivers/input/touchscreen/sx8654.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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"); -- 2.20.1