[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20220112020950.656796-1-mirela.rabulea@oss.nxp.com>
Date: Wed, 12 Jan 2022 04:09:50 +0200
From: Mirela Rabulea <mirela.rabulea@....nxp.com>
To: mchehab@...nel.org, shawnguo@...nel.org, s.hauer@...gutronix.de,
ming.qian@....com
Cc: linux-media@...r.kernel.org, linux-imx@....com,
kernel@...gutronix.de, linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org, festevam@...il.com,
robert.chiras@....com
Subject: [PATCH] media: imx-jpeg: Prevent decoding NV12M jpegs into single-planar buffers
If the application queues an NV12M jpeg as output buffer, but then
queues a single planar capture buffer, the kernel will crash with
"Unable to handle kernel NULL pointer dereference" in mxc_jpeg_addrs,
prevent this by finishing the job with error.
Signed-off-by: Mirela Rabulea <mirela.rabulea@....nxp.com>
---
drivers/media/platform/imx-jpeg/mxc-jpeg.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/media/platform/imx-jpeg/mxc-jpeg.c b/drivers/media/platform/imx-jpeg/mxc-jpeg.c
index 4ca96cf9def7..6acb17318cf4 100644
--- a/drivers/media/platform/imx-jpeg/mxc-jpeg.c
+++ b/drivers/media/platform/imx-jpeg/mxc-jpeg.c
@@ -947,6 +947,11 @@ static void mxc_jpeg_device_run(void *priv)
v4l2_m2m_buf_copy_metadata(src_buf, dst_buf, true);
jpeg_src_buf = vb2_to_mxc_buf(&src_buf->vb2_buf);
+ if (q_data_cap->fmt->colplanes == 2 &&
+ dst_buf->vb2_buf.num_planes < 2) {
+ dev_err(dev, "Decoding multi-planar, but capture buffer is single-planar\n");
+ jpeg_src_buf->jpeg_parse_error = true;
+ }
if (jpeg_src_buf->jpeg_parse_error) {
jpeg->slot_data[ctx->slot].used = false;
v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx);
--
2.25.1
Powered by blists - more mailing lists