lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Sat, 12 Sep 2020 20:51:20 +0200
From:   Mauro Carvalho Chehab <mchehab+huawei@...nel.org>
To:     unlisted-recipients:; (no To-header on input)
Cc:     Mauro Carvalho Chehab <mchehab+huawei@...nel.org>,
        "Daniel W. S. Almeida" <dwlsalmeida@...il.com>,
        Mauro Carvalho Chehab <mchehab@...nel.org>,
        linux-kernel@...r.kernel.org, linux-media@...r.kernel.org
Subject: [PATCH 1/2] media: vidtv: fix frequency tuning logic

Right now, there are some issues at the tuning logic:

1) the config struct is not copied at the tuner driver.
   so, it won't use any frequency table at all;
2) the code that checks for frequency shifts is called
   at set_params. So, lock_status will never be zeroed;
3) the signal strength will also report a strong
   signal, even if not tuned;
4) the logic is not excluding non-set frequencies.

Fix those issues.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@...nel.org>
---
 drivers/media/test-drivers/vidtv/vidtv_tuner.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/media/test-drivers/vidtv/vidtv_tuner.c b/drivers/media/test-drivers/vidtv/vidtv_tuner.c
index 39e848ae5836..268f980c6de8 100644
--- a/drivers/media/test-drivers/vidtv/vidtv_tuner.c
+++ b/drivers/media/test-drivers/vidtv/vidtv_tuner.c
@@ -120,7 +120,7 @@ vidtv_tuner_get_dev(struct dvb_frontend *fe)
 	return i2c_get_clientdata(fe->tuner_priv);
 }
 
-static s32 vidtv_tuner_check_frequency_shift(struct dvb_frontend *fe)
+static int vidtv_tuner_check_frequency_shift(struct dvb_frontend *fe)
 {
 	struct vidtv_tuner_dev *tuner_dev = vidtv_tuner_get_dev(fe);
 	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
@@ -156,6 +156,8 @@ static s32 vidtv_tuner_check_frequency_shift(struct dvb_frontend *fe)
 	}
 
 	for (i = 0; i < array_sz; i++) {
+		if (!valid_freqs[i])
+			break;
 		shift = abs(c->frequency - valid_freqs[i]);
 
 		if (!shift)
@@ -177,6 +179,7 @@ static int
 vidtv_tuner_get_signal_strength(struct dvb_frontend *fe, u16 *strength)
 {
 	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
+	struct vidtv_tuner_dev *tuner_dev = vidtv_tuner_get_dev(fe);
 	const struct vidtv_tuner_cnr_to_qual_s *cnr2qual = NULL;
 	struct device *dev = fe->dvb->device;
 	u32 array_size = 0;
@@ -184,6 +187,10 @@ vidtv_tuner_get_signal_strength(struct dvb_frontend *fe, u16 *strength)
 	u32 i;
 
 	shift = vidtv_tuner_check_frequency_shift(fe);
+	if (shift < 0) {
+		tuner_dev->hw_state.lock_status = 0;
+		return shift;
+	}
 
 	switch (c->delivery_system) {
 	case SYS_DVBT:
@@ -288,6 +295,7 @@ static int vidtv_tuner_set_params(struct dvb_frontend *fe)
 	struct vidtv_tuner_dev *tuner_dev = vidtv_tuner_get_dev(fe);
 	struct vidtv_tuner_config config  = tuner_dev->config;
 	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
+	s32 shift;
 
 	u32 min_freq = fe->ops.tuner_ops.info.frequency_min_hz;
 	u32 max_freq = fe->ops.tuner_ops.info.frequency_max_hz;
@@ -305,6 +313,13 @@ static int vidtv_tuner_set_params(struct dvb_frontend *fe)
 	tuner_dev->hw_state.lock_status = TUNER_STATUS_LOCKED;
 
 	msleep_interruptible(config.mock_tune_delay_msec);
+
+	shift = vidtv_tuner_check_frequency_shift(fe);
+	if (shift < 0) {
+		tuner_dev->hw_state.lock_status = 0;
+		return shift;
+	}
+
 	return 0;
 }
 
@@ -395,6 +410,7 @@ static int vidtv_tuner_i2c_probe(struct i2c_client *client,
 	       &vidtv_tuner_ops,
 	       sizeof(struct dvb_tuner_ops));
 
+	memcpy(&tuner_dev->config, config, sizeof(tuner_dev->config));
 	fe->tuner_priv = client;
 
 	return 0;
-- 
2.26.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ