[media] cxd2820r: fix gpio null pointer dereference
authorAntti Palosaari <crope@iki.fi>
Mon, 16 Jan 2017 21:27:41 +0000 (19:27 -0200)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Tue, 31 Jan 2017 10:45:41 +0000 (08:45 -0200)
Setting GPIOs during probe causes null pointer deference when
GPIOLIB was not selected by Kconfig. Initialize driver private
field before calling set gpios.

It is regressing bug since 4.9.

Fixes: 07fdf7d9f19f ("[media] cxd2820r: add I2C driver bindings")

Reported-by: Chris Rankin <rankincj@gmail.com>
Tested-by: Chris Rankin <rankincj@gmail.com>
Tested-by: Håkan Lennestål <hakan.lennestal@gmail.com>
Cc: <stable@vger.kernel.org> # v4.9+
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/media/dvb-frontends/cxd2820r_core.c

index 95267c6edb3a1357c463eabe4352ba40a9cc8319..f6ebbb47b9b2b9eedc62fa8789b969cae97fac04 100644 (file)
@@ -615,6 +615,7 @@ static int cxd2820r_probe(struct i2c_client *client,
        }
 
        priv->client[0] = client;
+       priv->fe.demodulator_priv = priv;
        priv->i2c = client->adapter;
        priv->ts_mode = pdata->ts_mode;
        priv->ts_clk_inv = pdata->ts_clk_inv;
@@ -697,7 +698,6 @@ static int cxd2820r_probe(struct i2c_client *client,
        memcpy(&priv->fe.ops, &cxd2820r_ops, sizeof(priv->fe.ops));
        if (!pdata->attach_in_use)
                priv->fe.ops.release = NULL;
-       priv->fe.demodulator_priv = priv;
        i2c_set_clientdata(client, priv);
 
        /* Setup callbacks */