]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
media: renesas: vsp1: histo: Fix code enumeration
authorLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Wed, 18 Mar 2026 23:59:03 +0000 (01:59 +0200)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Wed, 25 Mar 2026 09:25:49 +0000 (10:25 +0100)
The histogram media bus code enumeration does not check the index when
operating on the source pad, resulting in an infinite loop if userspace
keeps enumerating code without any loop boundary. Fix it by returning an
error for indices larger than 0 as the pad supports a single format.

Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # HiHope RZ/G2M
Link: https://patch.msgid.link/20260318235907.831556-10-laurent.pinchart+renesas@ideasonboard.com
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/media/platform/renesas/vsp1/vsp1_histo.c

index d7843c170f944df00bef836815d1823f0d25d2b5..f97aecb22058179a5ade4bd6d05ecedea114d7fe 100644 (file)
@@ -168,7 +168,10 @@ static int histo_enum_mbus_code(struct v4l2_subdev *subdev,
                                struct v4l2_subdev_mbus_code_enum *code)
 {
        if (code->pad == HISTO_PAD_SOURCE) {
-               code->code = MEDIA_BUS_FMT_FIXED;
+               if (code->index > 0)
+                       return -EINVAL;
+
+               code->code = MEDIA_BUS_FMT_METADATA_FIXED;
                return 0;
        }