CVE-2022-48975

Source
https://cve.org/CVERecord?id=CVE-2022-48975
Import Source
https://storage.googleapis.com/osv-test-cve-osv-conversion/osv-output/CVE-2022-48975.json
JSON Data
https://api.test.osv.dev/v1/vulns/CVE-2022-48975
Downstream
Related
Published
2024-10-21T20:05:55.091Z
Modified
2026-03-12T03:24:27.644296Z
Summary
gpiolib: fix memory leak in gpiochip_setup_dev()
Details

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 gpiochipadddatawith_key

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 device_del().

Therefore, after deviceadd() succeeds by gcdevregister(), it needs to call put_device() 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 put_device() 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 ZERO_PTR 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.

Database specific
{
    "osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2022/48xxx/CVE-2022-48975.json",
    "cna_assigner": "Linux"
}
References

Affected packages

Git / git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git

Affected ranges

Type
GIT
Repo
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
Events
Introduced
159f3cd92f17c61a4e2a47456de5865b114ef88e
Fixed
6daaa84b621485fe28c401be18debf92ae8ef04a
Fixed
371363716398ed718e389bea8c5e9843a79dde4e
Fixed
ec851b23084b3a0af8bf0f5e51d33a8d678bdc49

Database specific

source
"https://storage.googleapis.com/osv-test-cve-osv-conversion/osv-output/CVE-2022-48975.json"