All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] media: lgdt330x: don't use an uninitialized state
@ 2018-05-04 15:18 Mauro Carvalho Chehab
  0 siblings, 0 replies; only message in thread
From: Mauro Carvalho Chehab @ 2018-05-04 15:18 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List, Mauro Carvalho Chehab

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 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/media/dvb-frontends/lgdt330x.c b/drivers/media/dvb-frontends/lgdt330x.c
index 927fd68e05ec..f6731738b073 100644
--- a/drivers/media/dvb-frontends/lgdt330x.c
+++ b/drivers/media/dvb-frontends/lgdt330x.c
@@ -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,
-- 
2.17.0

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2018-05-04 15:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-04 15:18 [PATCH] media: lgdt330x: don't use an uninitialized state Mauro Carvalho Chehab

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.