V4L/DVB (4311): Fix possible dvb-pll oops
Supplying a NULL i2c adapter to dvb_pll_attach is allowed, for example with
mt352 demods. However, the pll i2c probe will segfault because it does not
check for this.
Signed-off-by: Andrew de Quincey <adq_dvb@lidskialf.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
diff --git a/drivers/media/dvb/frontends/dvb-pll.c b/drivers/media/dvb/frontends/dvb-pll.c
index fce5c42..4c8a506 100644
--- a/drivers/media/dvb/frontends/dvb-pll.c
+++ b/drivers/media/dvb/frontends/dvb-pll.c
@@ -619,14 +619,16 @@
struct dvb_pll_priv *priv = NULL;
int ret;
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
+ if (i2c != NULL) {
+ if (fe->ops.i2c_gate_ctrl)
+ fe->ops.i2c_gate_ctrl(fe, 1);
- ret = i2c_transfer (i2c, msg, 2);
- if (ret != 2)
- return -1;
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 0);
+ ret = i2c_transfer (i2c, msg, 2);
+ if (ret != 2)
+ return -1;
+ if (fe->ops.i2c_gate_ctrl)
+ fe->ops.i2c_gate_ctrl(fe, 0);
+ }
priv = kzalloc(sizeof(struct dvb_pll_priv), GFP_KERNEL);
if (priv == NULL)