Skip to content

Commit 576a307

Browse files
committed
media: cx24116: prevent overflows on SNR calculus
as reported by Coverity, if reading SNR registers fail, a negative number will be returned, causing an underflow when reading SNR registers. Prevent that. Fixes: 8953db7 ("V4L/DVB (9178): cx24116: Add module parameter to return SNR as ESNO.") Cc: stable@vger.kernel.org Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
1 parent 438d308 commit 576a307

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

drivers/media/dvb-frontends/cx24116.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,7 @@ static int cx24116_read_snr_pct(struct dvb_frontend *fe, u16 *snr)
741741
{
742742
struct cx24116_state *state = fe->demodulator_priv;
743743
u8 snr_reading;
744+
int ret;
744745
static const u32 snr_tab[] = { /* 10 x Table (rounded up) */
745746
0x00000, 0x0199A, 0x03333, 0x04ccD, 0x06667,
746747
0x08000, 0x0999A, 0x0b333, 0x0cccD, 0x0e667,
@@ -749,7 +750,11 @@ static int cx24116_read_snr_pct(struct dvb_frontend *fe, u16 *snr)
749750

750751
dprintk("%s()\n", __func__);
751752

752-
snr_reading = cx24116_readreg(state, CX24116_REG_QUALITY0);
753+
ret = cx24116_readreg(state, CX24116_REG_QUALITY0);
754+
if (ret < 0)
755+
return ret;
756+
757+
snr_reading = ret;
753758

754759
if (snr_reading >= 0xa0 /* 100% */)
755760
*snr = 0xffff;

0 commit comments

Comments
 (0)