* [PATCH] media: imx-jpeg: Prevent decoding NV12M jpegs into single-planar buffers
@ 2022-01-12 2:09 Mirela Rabulea
0 siblings, 0 replies; only message in thread
From: Mirela Rabulea @ 2022-01-12 2:09 UTC (permalink / raw)
To: mchehab, shawnguo, s.hauer, ming.qian
Cc: linux-media, linux-imx, kernel, linux-arm-kernel, linux-kernel,
festevam, robert.chiras
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@oss.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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-01-12 2:10 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-12 2:09 [PATCH] media: imx-jpeg: Prevent decoding NV12M jpegs into single-planar buffers Mirela Rabulea
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).