Skip to content

Commit 97dbf8e

Browse files
Sergey Shtylyovgregkh
authored andcommitted
media: dib8000: avoid division by 0 in dib8000_set_dds()
commit dde3c37 upstream. In dib8000_set_dds(), 1 << 26 (67108864) divided by e.g. 1 apparently can't fit into 16-bit variable unit_khz_dds_val, being truncated to 0; this will cause division by 0 while calling dprintk() with debugging enabled (via the module parameter). Use s32 instead of s16 to declare the variable, getting rid of the cast to u16 in the *else* branch as well... Found by Linux Verification Center (linuxtesting.org) with the Svace static analysis tool. Fixes: 173a64c ("[media] dib8000: enhancement") Cc: stable@vger.kernel.org Signed-off-by: Sergey Shtylyov <s.shtylyov@auroraos.dev> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 492c529 commit 97dbf8e

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

drivers/media/dvb-frontends/dib8000.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2694,7 +2694,7 @@ static void dib8000_viterbi_state(struct dib8000_state *state, u8 onoff)
26942694

26952695
static void dib8000_set_dds(struct dib8000_state *state, s32 offset_khz)
26962696
{
2697-
s16 unit_khz_dds_val;
2697+
s32 unit_khz_dds_val;
26982698
u32 abs_offset_khz = abs(offset_khz);
26992699
u32 dds = state->cfg.pll->ifreq & 0x1ffffff;
27002700
u8 invert = !!(state->cfg.pll->ifreq & (1 << 25));
@@ -2715,7 +2715,7 @@ static void dib8000_set_dds(struct dib8000_state *state, s32 offset_khz)
27152715
dds = (1<<26) - dds;
27162716
} else {
27172717
ratio = 2;
2718-
unit_khz_dds_val = (u16) (67108864 / state->cfg.pll->internal);
2718+
unit_khz_dds_val = 67108864 / state->cfg.pll->internal;
27192719

27202720
if (offset_khz < 0)
27212721
unit_khz_dds_val *= -1;

0 commit comments

Comments
 (0)