Linux Media Controller development
 help / color / mirror / Atom feed
* [PATCH v2 1/2] media: s2255: Rename CamelCase goto labels to snake_case
@ 2026-07-15  9:29 Lei Huang
  2026-07-15  9:29 ` [PATCH v2 2/2] media: s2255: check firmware size before reading trailing marker Lei Huang
  2026-07-15 10:00 ` [PATCH v2 1/2] media: s2255: Rename CamelCase goto labels to snake_case Johan Hovold
  0 siblings, 2 replies; 4+ messages in thread
From: Lei Huang @ 2026-07-15  9:29 UTC (permalink / raw)
  To: mchehab; +Cc: johan, hverkuil+cisco, linux-media, linux-kernel, Lei Huang

From: Lei Huang <huanglei@kylinos.cn>

Rename the error-path goto labels in s2255_probe() from CamelCase to
snake_case to comply with the Linux kernel coding style:

  errorBOARDINIT -> err_boardinit
  errorFWMARKER  -> err_fwmarker
  errorREQFW     -> err_reqfw
  errorFWDATA2   -> err_fwdata2
  errorFWURB     -> err_fwurb
  errorEP        -> err_ep
  errorUDEV      -> err_udev
  errorFWDATA1   -> err_fwdata1

No functional changes; all label definitions and goto references are
updated consistently.

Signed-off-by: Lei Huang <huanglei@kylinos.cn>
---
 drivers/media/usb/s2255/s2255drv.c | 36 +++++++++++++++---------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/media/usb/s2255/s2255drv.c b/drivers/media/usb/s2255/s2255drv.c
index 0b8182edf8e4..f22f6ad4e8ba 100644
--- a/drivers/media/usb/s2255/s2255drv.c
+++ b/drivers/media/usb/s2255/s2255drv.c
@@ -2216,14 +2216,14 @@ static int s2255_probe(struct usb_interface *interface,
 	dev->cmdbuf = kzalloc(S2255_CMDBUF_SIZE, GFP_KERNEL);
 	if (dev->cmdbuf == NULL) {
 		s2255_dev_err(&interface->dev, "out of memory\n");
-		goto errorFWDATA1;
+		goto err_fwdata1;
 	}
 
 	refcount_set(&dev->num_channels, 0);
 	dev->pid = id->idProduct;
 	dev->fw_data = kzalloc_obj(struct s2255_fw);
 	if (!dev->fw_data)
-		goto errorFWDATA1;
+		goto err_fwdata1;
 	mutex_init(&dev->lock);
 	mutex_init(&dev->cmdlock);
 	/* grab usb_device and save it */
@@ -2231,7 +2231,7 @@ static int s2255_probe(struct usb_interface *interface,
 	if (dev->udev == NULL) {
 		dev_err(&interface->dev, "null usb device\n");
 		retval = -ENODEV;
-		goto errorUDEV;
+		goto err_udev;
 	}
 	dev_dbg(&interface->dev, "dev: %p, udev %p interface %p\n",
 		dev, dev->udev, interface);
@@ -2243,7 +2243,7 @@ static int s2255_probe(struct usb_interface *interface,
 
 	if (usb_find_bulk_in_endpoint(iface_desc, &endpoint)) {
 		dev_err(&interface->dev, "Could not find bulk-in endpoint\n");
-		goto errorEP;
+		goto err_ep;
 	}
 
 	dev->read_endpoint = endpoint->bEndpointAddress;
@@ -2262,18 +2262,18 @@ static int s2255_probe(struct usb_interface *interface,
 
 	dev->fw_data->fw_urb = usb_alloc_urb(0, GFP_KERNEL);
 	if (!dev->fw_data->fw_urb)
-		goto errorFWURB;
+		goto err_fwurb;
 
 	dev->fw_data->pfw_data = kzalloc(CHUNK_SIZE, GFP_KERNEL);
 	if (!dev->fw_data->pfw_data) {
 		dev_err(&interface->dev, "out of memory!\n");
-		goto errorFWDATA2;
+		goto err_fwdata2;
 	}
 	/* load the first chunk */
 	if (request_firmware(&dev->fw_data->fw,
 			     FIRMWARE_FILE_NAME, &dev->udev->dev)) {
 		dev_err(&interface->dev, "sensoray 2255 failed to get firmware\n");
-		goto errorREQFW;
+		goto err_reqfw;
 	}
 	/* check the firmware is valid */
 	fw_size = dev->fw_data->fw->size;
@@ -2282,7 +2282,7 @@ static int s2255_probe(struct usb_interface *interface,
 	if (*pdata != S2255_FW_MARKER) {
 		dev_err(&interface->dev, "Firmware invalid.\n");
 		retval = -ENODEV;
-		goto errorFWMARKER;
+		goto err_fwmarker;
 	} else {
 		/* make sure firmware is the latest */
 		__le32 *pRel;
@@ -2300,30 +2300,30 @@ static int s2255_probe(struct usb_interface *interface,
 	/* load 2255 board specific */
 	retval = s2255_board_init(dev);
 	if (retval)
-		goto errorBOARDINIT;
+		goto err_boardinit;
 	s2255_fwload_start(dev);
 	/* loads v4l specific */
 	retval = s2255_probe_v4l(dev);
 	if (retval)
-		goto errorBOARDINIT;
+		goto err_boardinit;
 	dev_info(&interface->dev, "Sensoray 2255 detected\n");
 	return 0;
-errorBOARDINIT:
+err_boardinit:
 	s2255_board_shutdown(dev);
-errorFWMARKER:
+err_fwmarker:
 	release_firmware(dev->fw_data->fw);
-errorREQFW:
+err_reqfw:
 	kfree(dev->fw_data->pfw_data);
-errorFWDATA2:
+err_fwdata2:
 	usb_free_urb(dev->fw_data->fw_urb);
-errorFWURB:
+err_fwurb:
 	timer_shutdown_sync(&dev->timer);
-errorEP:
+err_ep:
 	usb_put_dev(dev->udev);
-errorUDEV:
+err_udev:
 	kfree(dev->fw_data);
 	mutex_destroy(&dev->lock);
-errorFWDATA1:
+err_fwdata1:
 	kfree(dev->cmdbuf);
 	kfree(dev);
 	pr_warn("Sensoray 2255 driver load failed: 0x%x\n", retval);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] media: s2255: check firmware size before reading trailing marker
  2026-07-15  9:29 [PATCH v2 1/2] media: s2255: Rename CamelCase goto labels to snake_case Lei Huang
@ 2026-07-15  9:29 ` Lei Huang
  2026-07-15 10:00 ` [PATCH v2 1/2] media: s2255: Rename CamelCase goto labels to snake_case Johan Hovold
  1 sibling, 0 replies; 4+ messages in thread
From: Lei Huang @ 2026-07-15  9:29 UTC (permalink / raw)
  To: mchehab; +Cc: johan, hverkuil+cisco, linux-media, linux-kernel, Lei Huang

From: Lei Huang <huanglei@kylinos.cn>

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.

Re-applied after the CamelCase cleanup renamed the error label from
errorFWMARKER to err_fwmarker.

Fixes: 14d962602c8b ("V4L/DVB (8752): s2255drv: firmware improvement patch")
Signed-off-by: Lei Huang <huanglei@kylinos.cn>
---
 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 f22f6ad4e8ba..64140b780e63 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 err_fwmarker;
+	}
 	pdata = (__le32 *) &dev->fw_data->fw->data[fw_size - 8];
 
 	if (*pdata != S2255_FW_MARKER) {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/2] media: s2255: Rename CamelCase goto labels to snake_case
  2026-07-15  9:29 [PATCH v2 1/2] media: s2255: Rename CamelCase goto labels to snake_case Lei Huang
  2026-07-15  9:29 ` [PATCH v2 2/2] media: s2255: check firmware size before reading trailing marker Lei Huang
@ 2026-07-15 10:00 ` Johan Hovold
  2026-07-15 12:05   ` hverkuil+cisco
  1 sibling, 1 reply; 4+ messages in thread
From: Johan Hovold @ 2026-07-15 10:00 UTC (permalink / raw)
  To: Lei Huang; +Cc: mchehab, hverkuil+cisco, linux-media, linux-kernel, Lei Huang

On Wed, Jul 15, 2026 at 05:29:46PM +0800, Lei Huang wrote:
> From: Lei Huang <huanglei@kylinos.cn>
> 
> Rename the error-path goto labels in s2255_probe() from CamelCase to
> snake_case to comply with the Linux kernel coding style:
> 
>   errorBOARDINIT -> err_boardinit
>   errorFWMARKER  -> err_fwmarker
>   errorREQFW     -> err_reqfw
>   errorFWDATA2   -> err_fwdata2
>   errorFWURB     -> err_fwurb
>   errorEP        -> err_ep
>   errorUDEV      -> err_udev
>   errorFWDATA1   -> err_fwdata1
> 
> No functional changes; all label definitions and goto references are
> updated consistently.
> 
> Signed-off-by: Lei Huang <huanglei@kylinos.cn>

This looks ok, but the fix should go before the cleanup (e.g. to
facilitate backporting).

Also, always include a changelog (in a coverletter) when updating a
series.

Johan

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/2] media: s2255: Rename CamelCase goto labels to snake_case
  2026-07-15 10:00 ` [PATCH v2 1/2] media: s2255: Rename CamelCase goto labels to snake_case Johan Hovold
@ 2026-07-15 12:05   ` hverkuil+cisco
  0 siblings, 0 replies; 4+ messages in thread
From: hverkuil+cisco @ 2026-07-15 12:05 UTC (permalink / raw)
  To: Johan Hovold, Lei Huang; +Cc: mchehab, linux-media, linux-kernel, Lei Huang

On 15/07/2026 12:00, Johan Hovold wrote:
> On Wed, Jul 15, 2026 at 05:29:46PM +0800, Lei Huang wrote:
>> From: Lei Huang <huanglei@kylinos.cn>
>>
>> Rename the error-path goto labels in s2255_probe() from CamelCase to
>> snake_case to comply with the Linux kernel coding style:
>>
>>   errorBOARDINIT -> err_boardinit
>>   errorFWMARKER  -> err_fwmarker
>>   errorREQFW     -> err_reqfw
>>   errorFWDATA2   -> err_fwdata2
>>   errorFWURB     -> err_fwurb
>>   errorEP        -> err_ep
>>   errorUDEV      -> err_udev
>>   errorFWDATA1   -> err_fwdata1
>>
>> No functional changes; all label definitions and goto references are
>> updated consistently.
>>
>> Signed-off-by: Lei Huang <huanglei@kylinos.cn>
> 
> This looks ok, but the fix should go before the cleanup (e.g. to
> facilitate backporting).

I'll just take the v1 patch and Lei Huang can make a cleanup patch on
top of that. It is nice to get rid of the camelCase labels.

Regards,

	Hans

> 
> Also, always include a changelog (in a coverletter) when updating a
> series.
> 
> Johan
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-07-15 12:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-15  9:29 [PATCH v2 1/2] media: s2255: Rename CamelCase goto labels to snake_case Lei Huang
2026-07-15  9:29 ` [PATCH v2 2/2] media: s2255: check firmware size before reading trailing marker Lei Huang
2026-07-15 10:00 ` [PATCH v2 1/2] media: s2255: Rename CamelCase goto labels to snake_case Johan Hovold
2026-07-15 12:05   ` hverkuil+cisco

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox