Subject: CVE-2024-27077: media: v4l2-mem2mem: fix a memleak in v4l2_m2m_register_entity

From: Greg Kroah-Hartman <[email-masked]>

Description
===========

In the Linux kernel, the following vulnerability has been resolved:

media: v4l2-mem2mem: fix a memleak in v4l2_m2m_register_entity

The entity->name (i.e. name) is allocated in v4l2_m2m_register_entity
but isn't freed in its following error-handling paths. This patch
adds such deallocation to prevent memleak of entity->name.

The Linux kernel CVE team has assigned CVE-2024-27077 to this issue.

Affected and fixed versions
===========================

	Issue introduced in 4.19 with commit be2fff656322 and fixed in 4.19.311 with commit 3dd8abb0ed0e
	Issue introduced in 4.19 with commit be2fff656322 and fixed in 5.4.273 with commit 0175f2d34c85
	Issue introduced in 4.19 with commit be2fff656322 and fixed in 5.10.214 with commit afd2a82fe300
	Issue introduced in 4.19 with commit be2fff656322 and fixed in 5.15.153 with commit dc866b69cc51
	Issue introduced in 4.19 with commit be2fff656322 and fixed in 6.1.83 with commit 0c9550b032de
	Issue introduced in 4.19 with commit be2fff656322 and fixed in 6.6.23 with commit 90029b9c979b
	Issue introduced in 4.19 with commit be2fff656322 and fixed in 6.7.11 with commit 5dc319cc3c4f
	Issue introduced in 4.19 with commit be2fff656322 and fixed in 6.8.2 with commit 9c23ef30e840
	Issue introduced in 4.19 with commit be2fff656322 and fixed in 6.9 with commit 8f94b49a5b5d

Please see https://www.kernel.org for a full list of currently supported
kernel versions by the kernel community.

Unaffected versions might change over time as fixes are backported to
older supported kernel versions.  The official CVE entry at
	https://cve.org/CVERecord/?id=CVE-2024-27077
will be updated if fixes are backported, please check that for the most
up to date information about this issue.

Affected files
==============

The file(s) affected by this issue are:
	drivers/media/v4l2-core/v4l2-mem2mem.c

Mitigation
==========

The Linux kernel CVE team recommends that you update to the latest
stable kernel version for this, and many other bugfixes.  Individual
changes are never tested alone, but rather are part of a larger kernel
release.  Cherry-picking individual commits is not recommended or
supported by the Linux kernel community at all.  If however, updating to
the latest release is impossible, the individual changes to resolve this
issue can be found at these commits:
	https://git.kernel.org/stable/c/3dd8abb0ed0e0a7c66d6d677c86ccb188cc39333
	https://git.kernel.org/stable/c/0175f2d34c85744f9ad6554f696cf0afb5bd04e4
	https://git.kernel.org/stable/c/afd2a82fe300032f63f8be5d6cd6981e75f8bbf2
	https://git.kernel.org/stable/c/dc866b69cc51af9b8509b4731b8ce2a4950cd0ef
	https://git.kernel.org/stable/c/0c9550b032de48d6a7fa6a4ddc09699d64d9300d
	https://git.kernel.org/stable/c/90029b9c979b60de5cb2b70ade4bbf61d561bc5d
	https://git.kernel.org/stable/c/5dc319cc3c4f7b74f7dfba349aa26f87efb52458
	https://git.kernel.org/stable/c/9c23ef30e840fedc66948299509f6c2777c9cf4f
	https://git.kernel.org/stable/c/8f94b49a5b5d386c038e355bef6347298aabd211