]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
objtool, media: dib8000: Prevent divide-by-zero in dib8000_set_dds()
authorJosh Poimboeuf <jpoimboe@kernel.org>
Mon, 24 Mar 2025 21:56:06 +0000 (14:56 -0700)
committerIngo Molnar <mingo@kernel.org>
Tue, 25 Mar 2025 22:00:15 +0000 (23:00 +0100)
If dib8000_set_dds()'s call to dib8000_read32() returns zero, the result
is a divide-by-zero.  Prevent that from happening.

Fixes the following warning with an UBSAN kernel:

  drivers/media/dvb-frontends/dib8000.o: warning: objtool: dib8000_tune() falls through to next function dib8096p_cfg_DibRx()

Fixes: 173a64cb3fcf ("[media] dib8000: enhancement")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: https://lore.kernel.org/r/bd1d504d930ae3f073b1e071bcf62cae7708773c.1742852847.git.jpoimboe@kernel.org
Closes: https://lore.kernel.org/r/202503210602.fvH5DO1i-lkp@intel.com/
drivers/media/dvb-frontends/dib8000.c

index 2f5165918163dfff5733831045edd81a19bbc75c..cfe59c3255f706bb8c9279ea69b2aaea6c6cf360 100644 (file)
@@ -2701,8 +2701,11 @@ static void dib8000_set_dds(struct dib8000_state *state, s32 offset_khz)
        u8 ratio;
 
        if (state->revision == 0x8090) {
+               u32 internal = dib8000_read32(state, 23) / 1000;
+
                ratio = 4;
-               unit_khz_dds_val = (1<<26) / (dib8000_read32(state, 23) / 1000);
+
+               unit_khz_dds_val = (1<<26) / (internal ?: 1);
                if (offset_khz < 0)
                        dds = (1 << 26) - (abs_offset_khz * unit_khz_dds_val);
                else