Skip to contentSkip to conversation

CVE-2026-23137: of: unittest: Fix memory leak in unittest_data_add()

DISCUSSION Greg Kroah-Hartman 1 participant 1 message Feb 14

lore
Share & tools
lore
#0 lore raw

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

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

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

of: unittest: Fix memory leak in unittest_data_add()

In unittest_data_add(), if of_resolve_phandles() fails, the allocated unittest_data is not freed, leading to a memory leak.

Fix this by using scope-based cleanup helper __free(kfree) for automatic resource cleanup. This ensures unittest_data is automatically freed when it goes out of scope in error paths.

For the success path, use retain_and_null_ptr() to transfer ownership of the memory to the device tree and prevent double freeing.

The Linux kernel CVE team has assigned CVE-2026-23137 to this issue.

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

	Issue introduced in 3.18 with commit 2eb46da2a760e5764c48b752a5ef320e02b96b21 and fixed in 6.18.6 with commit f09b0f705bd7197863b90256ef533a6414d1db2c
	Issue introduced in 3.18 with commit 2eb46da2a760e5764c48b752a5ef320e02b96b21 and fixed in 6.19 with commit 235a1eb8d2dcc49a6cf0a5ee1aa85544a5d0054b

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-2026-23137

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/of/unittest.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/f09b0f705bd7197863b90256ef533a6414d1db2c
	https://git.kernel.org/stable/c/235a1eb8d2dcc49a6cf0a5ee1aa85544a5d0054b