]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
media: imx-jpeg: Cleanup after an allocation error
authorMing Qian <ming.qian@oss.nxp.com>
Mon, 21 Apr 2025 08:12:54 +0000 (16:12 +0800)
committerHans Verkuil <hverkuil@xs4all.nl>
Thu, 24 Apr 2025 13:21:37 +0000 (15:21 +0200)
When allocation failures are not cleaned up by the driver, further
allocation errors will be false-positives, which will cause buffers to
remain uninitialized and cause NULL pointer dereferences.
Ensure proper cleanup of failed allocations to prevent these issues.

Fixes: 2db16c6ed72c ("media: imx-jpeg: Add V4L2 driver for i.MX8 JPEG Encoder/Decoder")
Cc: stable@vger.kernel.org
Signed-off-by: Ming Qian <ming.qian@oss.nxp.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c

index 29d3d4b08dd10716c2980b020f631ef8bdb6d44c..8a25ea8905ae0bb2dc2902ca826822f8f9430e9e 100644 (file)
@@ -820,6 +820,7 @@ skip_alloc:
        return true;
 err:
        dev_err(jpeg->dev, "Could not allocate descriptors for slot %d", jpeg->slot_data.slot);
+       mxc_jpeg_free_slot_data(jpeg);
 
        return false;
 }