On Tue Jul 14 14:52:02 2026 +0800, Lei Huang wrote:
> 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")
> Cc: [email protected]
> Signed-off-by: Lei Huang <[email protected]>
> Signed-off-by: Hans Verkuil <[email protected]>

Patch committed.

Thanks,
Hans Verkuil

 drivers/media/usb/s2255/s2255drv.c | 5 +++++
 1 file changed, 5 insertions(+)

---

diff --git a/drivers/media/usb/s2255/s2255drv.c 
b/drivers/media/usb/s2255/s2255drv.c
index 0b8182edf8e4..3917913c3b47 100644
--- a/drivers/media/usb/s2255/s2255drv.c
+++ b/drivers/media/usb/s2255/s2255drv.c
@@ -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) {
_______________________________________________
linuxtv-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to