@@ -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,
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(-)