]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 6 Jul 2025 08:57:57 +0000 (10:57 +0200)
[ Upstream commit 7500bb9cf164edbb2c8117d57620227b1a4a8369 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c

index 3602324b254a658ee8b6bb8422658f230a00f157..6e8d95a2406fd4b148431978f84da4d69ec41886 100644 (file)
@@ -553,6 +553,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;
 }