media: s2255: check firmware size before reading trailing marker
PATCH 1/1 media: s2255: check firmware size before reading trailing marker
From: Lei Huang <[email protected]>
s2255_probe() reads a 4-byte marker and version from the last 8 bytes of the firmware blob (fw->data[fw_size - 8] and [fw_size - 4]). If the firmware file is shorter than 8 bytes, fw_size - 8 underflows and the access reads out of bounds. Validate the firmware size before indexing.
Fixes 14d962602c8b ("V4L/DVB (8752): s2255drv: firmware improvement patch")
Signed-off-by Lei Huang <[email protected]>
--- drivers/media/usb/s2255/s2255drv.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/media/usb/s2255/s2255drv.c +5 -0
@@ -2277,6 +2277,11 @@ static int s2255_probe(struct usb_interface *interface, }/* check the firmware is valid */ fw_size = dev->fw_data->fw->size; +if (fw_size <8 ) { +dev_err (&interface->dev,"Firmware invalid: too small.\n" ); + retval = -ENODEV ; + goto errorFWMARKER; + } pdata = (__le32 *) &dev->fw_data->fw->data[fw_size -8 ];if (*pdata !=S2255_FW_MARKER ) {
Signature · 1 line
2.25.1