]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
media: imx-jpeg: fix a bug of accessing array out of bounds
authorMing Qian <ming.qian@nxp.com>
Mon, 7 Feb 2022 06:28:43 +0000 (14:28 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 8 Apr 2022 12:06:40 +0000 (14:06 +0200)
commit20c8b90430c5d6c4a3936eaa7c35aac670581487
treecebf27e2fa7bbb88b76ad3ca2a771f4a6dae50b5
parent3509825520a4867e8192f1be50580c415ab4b5fc
media: imx-jpeg: fix a bug of accessing array out of bounds

[ Upstream commit 97558d170a1236280407e8d29a7d095d2c2ed554 ]

When error occurs in parsing jpeg, the slot isn't acquired yet, it may
be the default value MXC_MAX_SLOTS.
If the driver access the slot using the incorrect slot number, it will
access array out of bounds.
The result is the driver will change num_domains, which follows
slot_data in struct mxc_jpeg_dev.
Then the driver won't detach the pm domain at rmmod, which will lead to
kernel panic when trying to insmod again.

Signed-off-by: Ming Qian <ming.qian@nxp.com>
Reviewed-by: Mirela Rabulea <mirela.rabulea@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/media/platform/imx-jpeg/mxc-jpeg.c