diff mbox series

[16/17] media: st: delta: introduce 'err_too_many_comps' label

Message ID 20230126150657.367921-17-hverkuil-cisco@xs4all.nl (mailing list archive)
State New, archived
Headers show
Series media: sparse/smatch fixes | expand

Commit Message

Hans Verkuil Jan. 26, 2023, 3:06 p.m. UTC
The code mixed gotos and returns, which confused smatch. Add a
err_too_many_comps label to handle the error instead of a return,
this helps smatch understand the code, and it's a bit more consistent
as well.

This fixes this smatch warning:

delta-mjpeg-hdr.c:67 delta_mjpeg_read_sof() warn: missing unwind goto?

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Cc: Hugues Fruchet <hugues.fruchet@foss.st.com>
---
 .../platform/st/sti/delta/delta-mjpeg-hdr.c      | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/drivers/media/platform/st/sti/delta/delta-mjpeg-hdr.c b/drivers/media/platform/st/sti/delta/delta-mjpeg-hdr.c
index 90e5b2f72c82..c132487637d3 100644
--- a/drivers/media/platform/st/sti/delta/delta-mjpeg-hdr.c
+++ b/drivers/media/platform/st/sti/delta/delta-mjpeg-hdr.c
@@ -59,13 +59,8 @@  static int delta_mjpeg_read_sof(struct delta_ctx *pctx,
 	header->nb_of_components = *(u8 *)(data + offset);
 	offset += sizeof(u8);
 
-	if (header->nb_of_components >= MJPEG_MAX_COMPONENTS) {
-		dev_err(delta->dev,
-			"%s   unsupported number of components (%d > %d)\n",
-			pctx->name, header->nb_of_components,
-			MJPEG_MAX_COMPONENTS);
-		return -EINVAL;
-	}
+	if (header->nb_of_components >= MJPEG_MAX_COMPONENTS)
+		goto err_too_many_comps;
 
 	if ((offset + header->nb_of_components *
 	     sizeof(header->components[0])) > size)
@@ -78,6 +73,13 @@  static int delta_mjpeg_read_sof(struct delta_ctx *pctx,
 		"%s   sof: reached end of %d size input stream\n",
 		pctx->name, size);
 	return -ENODATA;
+
+err_too_many_comps:
+	dev_err(delta->dev,
+		"%s   unsupported number of components (%d > %d)\n",
+		pctx->name, header->nb_of_components,
+		MJPEG_MAX_COMPONENTS);
+	return -EINVAL;
 }
 
 int delta_mjpeg_read_header(struct delta_ctx *pctx,