Subject: CVE-2024-36940: pinctrl: core: delete incorrect free in pinctrl_enable()

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

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

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

pinctrl: core: delete incorrect free in pinctrl_enable()

The "pctldev" struct is allocated in devm_pinctrl_register_and_init().
It's a devm_ managed pointer that is freed by devm_pinctrl_dev_release(),
so freeing it in pinctrl_enable() will lead to a double free.

The devm_pinctrl_dev_release() function frees the pindescs and destroys
the mutex as well.

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

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

	Issue introduced in 4.11 with commit 6118714275f0 and fixed in 4.19.314 with commit 735f4c6b6771
	Issue introduced in 4.11 with commit 6118714275f0 and fixed in 5.4.276 with commit cdaa171473d9
	Issue introduced in 4.11 with commit 6118714275f0 and fixed in 5.10.217 with commit 288bc4aa75f1
	Issue introduced in 4.11 with commit 6118714275f0 and fixed in 5.15.159 with commit 41f88ef8ba38
	Issue introduced in 4.11 with commit 6118714275f0 and fixed in 6.1.91 with commit ac7d65795827
	Issue introduced in 4.11 with commit 6118714275f0 and fixed in 6.6.31 with commit 558c8039fdf5
	Issue introduced in 4.11 with commit 6118714275f0 and fixed in 6.8.10 with commit f9f1e321d53e
	Issue introduced in 4.11 with commit 6118714275f0 and fixed in 6.9 with commit 5038a66dad01

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-36940
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/pinctrl/core.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/735f4c6b6771eafe336404c157ca683ad72a040d
	https://git.kernel.org/stable/c/cdaa171473d98962ae86f2a663d398fda2fbeefd
	https://git.kernel.org/stable/c/288bc4aa75f150d6f1ee82dd43c6da1b438b6068
	https://git.kernel.org/stable/c/41f88ef8ba387a12f4a2b8c400b6c9e8e54b2cca
	https://git.kernel.org/stable/c/ac7d65795827dc0cf7662384ed27caf4066bd72e
	https://git.kernel.org/stable/c/558c8039fdf596a584a92c171cbf3298919c448c
	https://git.kernel.org/stable/c/f9f1e321d53e4c5b666b66e5b43da29841fb55ba
	https://git.kernel.org/stable/c/5038a66dad0199de60e5671603ea6623eb9e5c79