drm/panel/raspberrypi-touchscreen: Avoid NULL deref if not initialised
authorDave Stevenson <dave.stevenson@raspberrypi.com>
Fri, 3 Sep 2021 16:47:37 +0000 (17:47 +0100)
committerPhil Elwell <8911409+pelwell@users.noreply.github.com>
Tue, 14 Sep 2021 12:04:20 +0000 (13:04 +0100)
If a call to rpi_touchscreen_i2c_write from rpi_touchscreen_probe
fails before mipi_dsi_device_register_full is called, then
in trying to log the error message if uses ts->dsi->dev when
it is still NULL.

Use ts->i2c->dev instead, which is initialised earlier in probe.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c

index 804bdcc..a6436f5 100644 (file)
@@ -257,7 +257,7 @@ static void rpi_touchscreen_i2c_write(struct rpi_touchscreen *ts,
 
        ret = i2c_smbus_write_byte_data(ts->i2c, reg, val);
        if (ret)
-               dev_err(&ts->dsi->dev, "I2C write failed: %d\n", ret);
+               dev_err(&ts->i2c->dev, "I2C write failed: %d\n", ret);
 }
 
 static int rpi_touchscreen_write(struct rpi_touchscreen *ts, u16 reg, u32 val)