# CVE-2021-47467: kunit: fix reference count leak in kfree_at_end

- Severity: Medium 5.3 (CVSS:3.1, scored by CISA-ADP) `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L`
- Known to be exploited: not in CISA's catalogue, which lists only what CISA has confirmed
- Likelihood of exploitation in the next 30 days (EPSS): 0.49%, higher than 43% of CVEs (2026-12-01)
- Published: 2024-05-22T06:23:26.324Z
- Modified: 2026-06-17T04:17:32.593Z
- SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial
- Assigned by: Linux

## Description

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

kunit: fix reference count leak in kfree_at_end

The reference counting issue happens in the normal path of
kfree_at_end(). When kunit_alloc_and_get_resource() is invoked, the
function forgets to handle the returned resource object, whose refcount
increased inside, causing a refcount leak.

Fix this issue by calling kunit_alloc_resource() instead of
kunit_alloc_and_get_resource().

Fixed the following when applying:
Shuah Khan <skhan@linuxfoundation.org>

CHECK: Alignment should match open parenthesis
+	kunit_alloc_resource(test, NULL, kfree_res_free, GFP_KERNEL,
 				     (void *)to_free);

(As written by CVE List.)

## Affected

- Linux Linux: from 1d71307a6f94df3750f8f884545a769e227172fe before bbdd158b40b66a9403391a517f24ef6613573446; from 1d71307a6f94df3750f8f884545a769e227172fe before f62314b1ced25c58b86e044fc951cd6a1ea234cf; 5.14 (not affected: before 5.14; from 5.14.15 up to 5.14.*; from 5.15 up to *)
- linux linux_kernel: from 5.14 before 5.14.15; 5.15

## References

- <https://git.kernel.org/stable/c/bbdd158b40b66a9403391a517f24ef6613573446> (patch)
- <https://git.kernel.org/stable/c/f62314b1ced25c58b86e044fc951cd6a1ea234cf> (patch)

## Sources

- CVE List: [CVE-2021-47467](https://www.cve.org/CVERecord?id=CVE-2021-47467), CVE Terms of Use, modified 2026-05-11
- NVD: [CVE-2021-47467](https://nvd.nist.gov/vuln/detail/CVE-2021-47467), Public domain, modified 2026-06-17

---

Page: https://cve.day/CVE-2021-47467 · Whole record: https://cve.day/CVE-2021-47467.json · Rebuilt by cve.day 2026-11-25T22:58:08.872Z
