linux-loongson/drivers/media/rc
Cosmin Tanislav c0b1da281d media: rc: ir-spi: avoid overflow in multiplication
Switch to u64 arithmetic and use DIV_ROUND_CLOSEST_ULL() to avoid
the overflow.

buffer[i] is unsigned int and is limited by the lirc core to
IR_MAX_DURATION, which is 500000.

idata->freq is u32, which has a max value of 0xFFFFFFFF.

In the case where buffer[i] is 500000, idata->freq overflows the u32
multiplication for any values >= 8590.

0xFFFFFFFF / 500000 ~= 8589

By casting buffer[i] to u64, idata->freq can be any u32 value without
overflowing the multiplication.

0xFFFFFFFFFFFFFFFF / 500000 ~= 36893488147419 (> 4294967295)

The result of the final operation will fit back into the unsigned int
limits without any issues.

500000 * 0xFFFFFFFF / 1000000 = 0x80000000 (< 0xFFFFFFFF)

Signed-off-by: Cosmin Tanislav <demonsingur@gmail.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
2025-06-23 12:11:04 +02:00
..
img-ir treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
keymaps media: rc: add keymap for Hauppauge Credit Card RC 2025-04-30 09:35:24 +02:00
ati_remote.c media: ati_remote: don't push static constants on stack for %*ph 2024-10-29 16:37:23 +01:00
bpf-lirc.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2024-02-22 15:29:26 -08:00
ene_ir.c treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
ene_ir.h
fintek-cir.c
fintek-cir.h
gpio-ir-recv.c media: Switch back to struct platform_driver::remove() 2024-10-12 16:28:25 +02:00
gpio-ir-tx.c media: gpio-ir-tx: Remove redundant call to local_irq_disable() 2024-10-08 11:07:45 +02:00
igorplugusb.c treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
iguanair.c media: rc: iguanair: handle timeouts 2024-12-11 19:48:17 +01:00
imon_raw.c media: imon: don't push static constants on stack for %*ph 2024-12-11 19:48:17 +01:00
imon.c treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
ir_toy.c move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
ir-hix5hd2.c media: Switch back to struct platform_driver::remove() 2024-10-12 16:28:25 +02:00
ir-imon-decoder.c
ir-jvc-decoder.c
ir-mce_kbd-decoder.c treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
ir-nec-decoder.c
ir-rc5-decoder.c
ir-rc6-decoder.c
ir-rcmm-decoder.c
ir-sanyo-decoder.c
ir-sharp-decoder.c media: sharp: fix sharp encoding 2023-10-11 16:26:16 +02:00
ir-sony-decoder.c
ir-spi.c media: rc: ir-spi: avoid overflow in multiplication 2025-06-23 12:11:04 +02:00
ir-xmp-decoder.c
ite-cir.c media: rc: remove unused tx_resolution field 2024-07-31 11:21:56 +02:00
ite-cir.h
Kconfig media: gpio-ir-tx: Driver does not behave with PREEMPT_RT 2024-10-08 11:07:45 +02:00
lirc_dev.c fdget(), trivial conversions 2024-11-03 01:28:06 -05:00
Makefile media: rc: remove ir-rx51 in favour of generic pwm-ir-tx 2023-09-27 09:40:02 +02:00
mceusb.c media: mceusb: don't include 'pm_wakeup.h' directly 2024-12-11 19:48:17 +01:00
meson-ir-tx.c media: meson-ir-tx: Drop usage of platform_driver_probe() 2023-11-16 13:56:48 +01:00
meson-ir.c media: Switch back to struct platform_driver::remove() 2024-10-12 16:28:25 +02:00
mtk-cir.c media: Switch back to struct platform_driver::remove() 2024-10-12 16:28:25 +02:00
nuvoton-cir.c
nuvoton-cir.h
pwm-ir-tx.c media: Switch to use hrtimer_setup() 2025-02-18 11:19:04 +01:00
rc-core-priv.h media: rc: reduce useless padding in struct rc_dev etc 2025-03-04 15:56:11 +01:00
rc-ir-raw.c treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
rc-loopback.c media: rc: remove unused tx_resolution field 2024-07-31 11:21:56 +02:00
rc-main.c treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
redrat3.c move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
serial_ir.c treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
st_rc.c media: Switch back to struct platform_driver::remove() 2024-10-12 16:28:25 +02:00
streamzap.c media: streamzap: prevent processing IR data on URB failure 2025-02-13 12:12:30 +01:00
sunxi-cir.c media: Switch back to struct platform_driver::remove() 2024-10-12 16:28:25 +02:00
ttusbir.c
winbond-cir.c
xbox_remote.c