Skip to contentSkip to conversation

cxd2820r: fix gpio null pointer dereference

PATCH In review Antti Palosaari 3 participants 4 messages Jan 16, 2017 – Jan 17, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cxd2820r: fix gpio null pointer dereference

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")
Cc <[email protected]> # v4.9+
---
 drivers/media/dvb-frontends/cxd2820r_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/dvb-frontends/cxd2820r_core.c +1 -1
index 95267c6..f6ebbb4 100644
@@ -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 */
Signature · 1 line
http://palosaari.fi/
#1 lore raw

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

Quoted 35 lines · Antti Palosaari

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")
Cc <[email protected]> # v4.9+
---
 drivers/media/dvb-frontends/cxd2820r_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/dvb-frontends/cxd2820r_core.c +1 -1
index 95267c6..f6ebbb4 100644
@@ -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 */
Signature · 1 line
http://palosaari.fi/
Tested-by
#2 lore raw
Quoted 3 lines · Antti Palosaari

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 :-)

[  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

#3 lore raw

Works here also !
Thanks.

/Håkan

Quoted 43 lines · Chris Rankin
Quoted 3 lines · Antti Palosaari

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 :-)

[  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