LinuxTV Patchwork [media] ts2020: Variable "utmp" in function ts2020_set_tuner_rf() could be uninitialized

login
register
mail settings
Submitter Yizhuo
Date Jan. 30, 2019, 5:33 p.m.
Message ID <20190130173331.4672-1-yzhai003@ucr.edu>
Download mbox | patch
Permalink /patch/54227/
State New
Delegated to: Sean Young
Headers show

Comments

Yizhuo - Jan. 30, 2019, 5:33 p.m.
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(-)

Patch

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;

Privacy Policy