CVE-2022-48975: gpiolib: fix memory leak in gpiochip_setup_dev()
In the Linux kernel, the following vulnerability has been resolved:
gpiolib: fix memory leak in gpiochipsetupdev()
Here is a backtrace report about memory leak detected in gpiochipsetupdev():
unreferenced object 0xffff88810b406400 (size 512): comm "python3", pid 1682, jiffies 4295346908 (age 24.090s) backtrace: kmalloctrace deviceadd deviceprivateinit at drivers/base/core.c:3361 (inlined by) deviceadd at drivers/base/core.c:3411 cdevdeviceadd gpiolibcdevregister gpiochipsetupdev gpiochipadddatawithkey
gcdevregister() & gcdevunregister() would call deviceadd() & devicedel() (no matter CONFIGGPIOCDEV is enabled or not) to register/unregister device.
However, if deviceadd() succeeds, some resource (like struct deviceprivate allocated by deviceprivateinit()) is not released by devicedel().
Therefore, after deviceadd() succeeds by gcdevregister(), it needs to call putdevice() to release resource in the error handle path.
Here we move forward the register of release function, and let it release every piece of resource by putdevice() instead of kfree().
While at it, fix another subtle issue, i.e. when gc->ngpio is equal to 0, we still call kcalloc() and, in case of further error, kfree() on the ZEROPTR pointer, which is not NULL. It's not a bug per se, but rather waste of the resources and potentially wrong expectation about contents of the gdev->descs variable.
Affected Software
Remediation
Event History
Frequently Asked Questions
What is the severity of CVE-2022-48975?
CVE-2022-48975 has a medium severity rating due to the potential for a memory leak in the Linux kernel.
How do I fix CVE-2022-48975?
To fix CVE-2022-48975, you should upgrade to the latest version of the Linux kernel that includes the patch for this vulnerability.
What versions of the Linux kernel are affected by CVE-2022-48975?
CVE-2022-48975 affects Linux kernel versions from 4.6 up to 5.15.83, and also from 5.16 to 6.1-rc8.
What component of the Linux kernel is affected by CVE-2022-48975?
CVE-2022-48975 specifically affects the gpiolib component in the Linux kernel.
Is CVE-2022-48975 exploitable remotely?
CVE-2022-48975 is not considered remotely exploitable as it requires local access to the affected system.