diff mbox

cxd2820r: fix gpio null pointer dereference

Message ID 20170116232934.8230-1-crope@iki.fi (mailing list archive)
State New, archived
Headers show

Commit Message

Antti Palosaari Jan. 16, 2017, 11:29 p.m. UTC
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>
Cc: <stable@vger.kernel.org> # v4.9+
Signed-off-by: Antti Palosaari <crope@iki.fi>
---
 drivers/media/dvb-frontends/cxd2820r_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Antti Palosaari Jan. 16, 2017, 11:40 p.m. UTC | #1
Chris and Håkan, test please without Kconfig CONFIG_GPIOLIB option. I 
cannot test it properly as there seems to quite many drivers selecting 
this option by default.

regards
Antti


On 01/17/2017 01:29 AM, Antti Palosaari wrote:
> 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>
> Cc: <stable@vger.kernel.org> # v4.9+
> Signed-off-by: Antti Palosaari <crope@iki.fi>
> ---
>  drivers/media/dvb-frontends/cxd2820r_core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/dvb-frontends/cxd2820r_core.c b/drivers/media/dvb-frontends/cxd2820r_core.c
> index 95267c6..f6ebbb4 100644
> --- a/drivers/media/dvb-frontends/cxd2820r_core.c
> +++ b/drivers/media/dvb-frontends/cxd2820r_core.c
> @@ -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 */
>
Chris Rankin Jan. 17, 2017, 8:43 p.m. UTC | #2
On 16 January 2017 at 23:40, Antti Palosaari <crope@iki.fi> wrote:
> Chris and Håkan, test please without Kconfig CONFIG_GPIOLIB option. I cannot
> test it properly as there seems to quite many drivers selecting this option
> by default.

Works here :-)

Tested-by: Chris Rankin <rankincj@gmail.com>

[  125.162762] usb 4-4: new high-speed USB device number 4 using ehci-pci
[  125.326832] em28xx: New device PCTV Systems PCTV 290e @ 480 Mbps
(2013:024f, interface 0, class 0)
[  125.334573] em28xx: DVB interface 0 found: isoc
[  125.337981] em28xx: chip ID is em28174
[  125.674813] em28174 #0: EEPROM ID = 26 00 01 00, EEPROM hash = 0x1eb936d2
[  125.680331] em28174 #0: EEPROM info:
[  125.682610] em28174 #0:      microcode start address = 0x0004, boot
configuration = 0x01
[  125.716963] em28174 #0:      No audio on board.
[  125.719856] em28174 #0:      500mA max power
[  125.722495] em28174 #0:      Table at offset 0x39, strings=0x1aa0,
0x14ba, 0x1ace
[  125.728384] em28174 #0: Identified as PCTV nanoStick T2 290e (card=78)
[  125.733669] em28174 #0: dvb set to isoc mode.
[  125.736863] usbcore: registered new interface driver em28xx
[  125.751373] em28174 #0: Binding DVB extension
[  125.763306] cxd2820r 11-006c: Sony CXD2820R successfully identified
[  125.770763] tda18271 11-0060: creating new instance
[  125.783435] tda18271: TDA18271HD/C2 detected @ 11-0060
[  125.980162] DVB: registering new adapter (em28174 #0)
[  125.983923] usb 4-4: DVB: registering adapter 0 frontend 0 (Sony CXD2820R)...
[  125.991316] em28174 #0: DVB extension successfully initialized
[  125.995962] em28xx: Registered (Em28xx dvb Extension) extension
[  126.003999] em28174 #0: Registering input extension
[  126.035656] Registered IR keymap rc-pinnacle-pctv-hd
[  126.039589] input: em28xx IR (em28174 #0) as
/devices/pci0000:00/0000:00:1d.7/usb4/4-4/rc/rc0/input23
[  126.047940] rc rc0: em28xx IR (em28174 #0) as
/devices/pci0000:00/0000:00:1d.7/usb4/4-4/rc/rc0
[  126.056022] em28174 #0: Input extension successfully initalized
[  126.060706] em28xx: Registered (Em28xx Input Extension) extension

Cheers,
Chris
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Håkan Lennestål Jan. 17, 2017, 11:14 p.m. UTC | #3
Works here also !
Thanks.

/Håkan

On 2017-01-17 21:43, Chris Rankin wrote:
> On 16 January 2017 at 23:40, Antti Palosaari <crope@iki.fi> wrote:
>> Chris and Håkan, test please without Kconfig CONFIG_GPIOLIB option. I cannot
>> test it properly as there seems to quite many drivers selecting this option
>> by default.
> Works here :-)
>
> Tested-by: Chris Rankin <rankincj@gmail.com>
>
> [  125.162762] usb 4-4: new high-speed USB device number 4 using ehci-pci
> [  125.326832] em28xx: New device PCTV Systems PCTV 290e @ 480 Mbps
> (2013:024f, interface 0, class 0)
> [  125.334573] em28xx: DVB interface 0 found: isoc
> [  125.337981] em28xx: chip ID is em28174
> [  125.674813] em28174 #0: EEPROM ID = 26 00 01 00, EEPROM hash = 0x1eb936d2
> [  125.680331] em28174 #0: EEPROM info:
> [  125.682610] em28174 #0:      microcode start address = 0x0004, boot
> configuration = 0x01
> [  125.716963] em28174 #0:      No audio on board.
> [  125.719856] em28174 #0:      500mA max power
> [  125.722495] em28174 #0:      Table at offset 0x39, strings=0x1aa0,
> 0x14ba, 0x1ace
> [  125.728384] em28174 #0: Identified as PCTV nanoStick T2 290e (card=78)
> [  125.733669] em28174 #0: dvb set to isoc mode.
> [  125.736863] usbcore: registered new interface driver em28xx
> [  125.751373] em28174 #0: Binding DVB extension
> [  125.763306] cxd2820r 11-006c: Sony CXD2820R successfully identified
> [  125.770763] tda18271 11-0060: creating new instance
> [  125.783435] tda18271: TDA18271HD/C2 detected @ 11-0060
> [  125.980162] DVB: registering new adapter (em28174 #0)
> [  125.983923] usb 4-4: DVB: registering adapter 0 frontend 0 (Sony CXD2820R)...
> [  125.991316] em28174 #0: DVB extension successfully initialized
> [  125.995962] em28xx: Registered (Em28xx dvb Extension) extension
> [  126.003999] em28174 #0: Registering input extension
> [  126.035656] Registered IR keymap rc-pinnacle-pctv-hd
> [  126.039589] input: em28xx IR (em28174 #0) as
> /devices/pci0000:00/0000:00:1d.7/usb4/4-4/rc/rc0/input23
> [  126.047940] rc rc0: em28xx IR (em28174 #0) as
> /devices/pci0000:00/0000:00:1d.7/usb4/4-4/rc/rc0
> [  126.056022] em28174 #0: Input extension successfully initalized
> [  126.060706] em28xx: Registered (Em28xx Input Extension) extension
>
> Cheers,
> Chris


--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/media/dvb-frontends/cxd2820r_core.c b/drivers/media/dvb-frontends/cxd2820r_core.c
index 95267c6..f6ebbb4 100644
--- a/drivers/media/dvb-frontends/cxd2820r_core.c
+++ b/drivers/media/dvb-frontends/cxd2820r_core.c
@@ -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 */