drivers/media/dvb-frontends/dib8000.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
The following commit has been merged into the objtool/urgent branch of tip:
Commit-ID: e63d465f59011dede0a0f1d21718b59a64c3ff5c
Gitweb: https://git.kernel.org/tip/e63d465f59011dede0a0f1d21718b59a64c3ff5c
Author: Josh Poimboeuf <jpoimboe@kernel.org>
AuthorDate: Mon, 24 Mar 2025 14:56:06 -07:00
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Tue, 25 Mar 2025 23:00:15 +01:00
objtool, media: dib8000: Prevent divide-by-zero in dib8000_set_dds()
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 | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/media/dvb-frontends/dib8000.c b/drivers/media/dvb-frontends/dib8000.c
index 2f51659..cfe59c3 100644
--- a/drivers/media/dvb-frontends/dib8000.c
+++ b/drivers/media/dvb-frontends/dib8000.c
@@ -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
Em Tue, 25 Mar 2025 22:09:58 -0000
"tip-bot2 for Josh Poimboeuf" <tip-bot2@linutronix.de> escreveu:
> The following commit has been merged into the objtool/urgent branch of tip:
>
> Commit-ID: e63d465f59011dede0a0f1d21718b59a64c3ff5c
> Gitweb: https://git.kernel.org/tip/e63d465f59011dede0a0f1d21718b59a64c3ff5c
> Author: Josh Poimboeuf <jpoimboe@kernel.org>
> AuthorDate: Mon, 24 Mar 2025 14:56:06 -07:00
> Committer: Ingo Molnar <mingo@kernel.org>
> CommitterDate: Tue, 25 Mar 2025 23:00:15 +01:00
>
> objtool, media: dib8000: Prevent divide-by-zero in dib8000_set_dds()
>
> 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 | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/dvb-frontends/dib8000.c b/drivers/media/dvb-frontends/dib8000.c
> index 2f51659..cfe59c3 100644
> --- a/drivers/media/dvb-frontends/dib8000.c
> +++ b/drivers/media/dvb-frontends/dib8000.c
> @@ -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);
This is theoretical, as in practice dib8096 won't likely be tuning
if reading this register would return zero, but at least for my
eyes, it would sound better to set unit_khz_dds_val to 1 internal
is zero, instead of 1<<26.
> if (offset_khz < 0)
> dds = (1 << 26) - (abs_offset_khz * unit_khz_dds_val);
> else
Regards,
Mauro
On Wed, Mar 26, 2025 at 06:42:39AM +0800, Mauro Carvalho Chehab wrote: > > + 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); > > This is theoretical, as in practice dib8096 won't likely be tuning > if reading this register would return zero, but at least for my > eyes, it would sound better to set unit_khz_dds_val to 1 internal > is zero, instead of 1<<26. I don't pretend to understand this device, I just figured one is the closest you can get to zero :-) So something like this instead? diff --git a/drivers/media/dvb-frontends/dib8000.c b/drivers/media/dvb-frontends/dib8000.c index cfe59c3255f7..c80134ff511b 100644 --- a/drivers/media/dvb-frontends/dib8000.c +++ b/drivers/media/dvb-frontends/dib8000.c @@ -2705,7 +2705,7 @@ static void dib8000_set_dds(struct dib8000_state *state, s32 offset_khz) ratio = 4; - unit_khz_dds_val = (1<<26) / (internal ?: 1); + unit_khz_dds_val = internal ? ((1<<26) / internal) : 1; if (offset_khz < 0) dds = (1 << 26) - (abs_offset_khz * unit_khz_dds_val); else
© 2016 - 2025 Red Hat, Inc.