All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [media] ts2020: Variable "utmp" in function ts2020_set_tuner_rf() could be uninitialized
@ 2019-01-30 17:33 Yizhuo
  0 siblings, 0 replies; only message in thread
From: Yizhuo @ 2019-01-30 17:33 UTC (permalink / raw)
  Cc: csong, zhiyunq, Yizhuo, Mauro Carvalho Chehab, linux-media, linux-kernel

In function ts2020_set_tuner_rf(), local variable "utmp" could
be uninitialized if function regmap_read() returns -EINVAL.
However, this value is used in if statement and written to
the register, which is potentially unsafe.

Signed-off-by: Yizhuo <yzhai003@ucr.edu>
---
 drivers/media/dvb-frontends/ts2020.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/media/dvb-frontends/ts2020.c b/drivers/media/dvb-frontends/ts2020.c
index 931e5c98da8a..e351039f2eae 100644
--- a/drivers/media/dvb-frontends/ts2020.c
+++ b/drivers/media/dvb-frontends/ts2020.c
@@ -177,9 +177,12 @@ static int ts2020_set_tuner_rf(struct dvb_frontend *fe)
 {
 	struct ts2020_priv *dev = fe->tuner_priv;
 	int ret;
-	unsigned int utmp;
+	unsigned int utmp = 0;
 
 	ret = regmap_read(dev->regmap, 0x3d, &utmp);
+	if (ret)
+		return ret;
+
 	utmp &= 0x7f;
 	if (utmp < 0x16)
 		utmp = 0xa1;
-- 
2.17.1


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

only message in thread, other threads:[~2019-01-30 17:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-30 17:33 [PATCH] [media] ts2020: Variable "utmp" in function ts2020_set_tuner_rf() could be uninitialized Yizhuo

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.