media: lgdt330x: don't use an uninitialized state
authorMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Fri, 4 May 2018 15:16:49 +0000 (11:16 -0400)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Fri, 4 May 2018 15:17:58 +0000 (11:17 -0400)
If state is not initialized or is freed, we can't use it:
drivers/media/dvb-frontends/lgdt330x.c:920 lgdt330x_probe() error: potential null dereference 'state'.  (kzalloc returns null)
drivers/media/dvb-frontends/lgdt330x.c:920 lgdt330x_probe() error: we previously assumed 'state' could be null (see line 878)
drivers/media/dvb-frontends/lgdt330x.c:920 lgdt330x_probe() error: dereferencing freed memory 'state'

Fixes: 23ba635d45f5 ("media: lgdt330x: convert it to the new I2C binding way")
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
drivers/media/dvb-frontends/lgdt330x.c

index 927fd68e05ecef414134c2f4454c1f2b718a8a27..f6731738b07313c317e0badf7be94c9ab49ddae1 100644 (file)
@@ -917,7 +917,8 @@ static int lgdt330x_probe(struct i2c_client *client,
 
 error:
        kfree(state);
-       dprintk(state, "ERROR\n");
+       if (debug)
+               dev_printk(KERN_DEBUG, &client->dev, "Error loading lgdt330x driver\n");
        return -ENODEV;
 }
 struct dvb_frontend *lgdt330x_attach(const struct lgdt330x_config *_config,