If no imx_media_pixfmt is found for a given mbus format code, we shouldn't crash. Return -EINVAL for any index. Signed-off-by: Philipp Zabel <p.zabel@xxxxxxxxxxxxxx> --- drivers/staging/media/imx/imx-media-csi.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index eb7be5093a9d..89903f267d60 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -1138,6 +1138,10 @@ static int csi_enum_mbus_code(struct v4l2_subdev *sd, infmt = __csi_get_fmt(priv, cfg, CSI_SINK_PAD, code->which); incc = imx_media_find_mbus_format(infmt->code, CS_SEL_ANY, true); + if (!incc) { + ret = -EINVAL; + goto out; + } switch (code->pad) { case CSI_SINK_PAD: -- 2.15.1