Skip to contentSkip to conversation

media: dw2102: Fix a buffer overflow

PATCH New Maksim Pinigin 1 participant 1 message Jul 5 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 media: dw2102: Fix a buffer overflow

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.

---
Changes in v2:
- Fix patch syntax

 drivers/media/usb/dvb-usb/dw2102.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/usb/dvb-usb/dw2102.c +1 -1
index 4fecf2f965e9..ad90d7be4412 100644
@@ -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);
Signature · 1 line
2.39.5