[PATCH v2] media: dw2102: Fix a buffer overflow

From: Maksim Pinigin

Date: Sun Jul 05 2026 - 10:46:35 EST


This bug in dw2102_load_firmware() function appears only when building the kernel via LLVM+Clang. Due to reading of 64 bytes chunk, it may happen that there will be an attempt to read a more bytes in chunk than there is left, which is why Kernel oops occurs.
At least this bug happens when downloading the firmware for Prof Revolution DVB-S2 7500 USB.

Signed-off-by: Maksim Pinigin <pinigin@xxxxxxxxxxx>
---
Changes in v2:
- Fix patch syntax

drivers/media/usb/dvb-usb/dw2102.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
index 4fecf2f965e9..ad90d7be4412 100644
--- a/drivers/media/usb/dvb-usb/dw2102.c
+++ b/drivers/media/usb/dvb-usb/dw2102.c
@@ -1893,7 +1893,7 @@ static int dw2102_load_firmware(struct usb_device *dev,
break;
}
info("start downloading DW210X firmware");
- p = kmalloc(fw->size, GFP_KERNEL);
+ p = kzalloc(round_up(fw->size, 0x40), GFP_KERNEL);
reset = 1;
/*stop the CPU*/
dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1, DW210X_WRITE_MSG);
--
2.39.5