Subject: CVE-2024-40939: net: wwan: iosm: Fix tainted pointer delete is case of region creation fail

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

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

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

net: wwan: iosm: Fix tainted pointer delete is case of region creation fail

In case of region creation fail in ipc_devlink_create_region(), previously
created regions delete process starts from tainted pointer which actually
holds error code value.
Fix this bug by decreasing region index before delete.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

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

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

	Issue introduced in 5.16 with commit 4dcd183fbd67 and fixed in 6.1.95 with commit fe394d59cdae
	Issue introduced in 5.16 with commit 4dcd183fbd67 and fixed in 6.6.35 with commit 040d93848703
	Issue introduced in 5.16 with commit 4dcd183fbd67 and fixed in 6.9.6 with commit 37a438704d19
	Issue introduced in 5.16 with commit 4dcd183fbd67 and fixed in 6.10 with commit b0c9a2643541

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-40939
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/net/wwan/iosm/iosm_ipc_devlink.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/fe394d59cdae81389dbf995e87c83c1acd120597
	https://git.kernel.org/stable/c/040d9384870386eb5dc55472ac573ac7756b2050
	https://git.kernel.org/stable/c/37a438704d19bdbe246d51d3749b6b3a8fe65afd
	https://git.kernel.org/stable/c/b0c9a26435413b81799047a7be53255640432547