CVE-2022-48975: gpiolib: fix memory leak in gpiochip_setup_dev()

Published Oct 21, 2024
·
Updated

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

10 affected components
Linux Linux kernel>=4.6<5.15.83
Linux Linux kernel>=5.16<6.0.13
Linux Linux kernel=6.1-rc1
Linux Linux kernel=6.1-rc2
Linux Linux kernel=6.1-rc3
Linux Linux kernel=6.1-rc4
Linux Linux kernel=6.1-rc5
Linux Linux kernel=6.1-rc6
Linux Linux kernel=6.1-rc7
Linux Linux kernel=6.1-rc8

Event History

Oct 21, 2024
CVE Published
via MITRE·08:05 PM
Data Sourced
via MITRE·08:05 PM
Description
Data Sourced
via NVD·08:15 PM
Description

Frequently Asked Questions

1

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.

2

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.

3

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.

4

What component of the Linux kernel is affected by CVE-2022-48975?

CVE-2022-48975 specifically affects the gpiolib component in the Linux kernel.

5

Is CVE-2022-48975 exploitable remotely?

CVE-2022-48975 is not considered remotely exploitable as it requires local access to the affected system.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203