CVE-2026-143246: gpiolib: fix GPIO descriptor leak in gpiod_get_array()
In the Linux kernel, the following vulnerability has been resolved:
gpiolib: fix GPIO descriptor leak in gpiodgetarray()
In gpiodgetarray(), descs->ndescs is used as the loop induction variable and is only incremented at the end of each iteration. When krealloc() fails on the first iteration (when index is 0), descs->desc[0] has already been acquired via gpiodgetindex(), but descs->ndescs is still 0. Consequently, gpiodputarray() frees descs without releasing descs->desc[0], leaking the descriptor.
Fix this by using a dedicated loop induction variable and incrementing descs->ndescs immediately upon storing the retrieved descriptor. Additionally, since the fast-path arrayinfo setup only executes for the first element (index 0), simplify the bitmapset() calls to start at bit 0 for count bits instead of calculating offsets from the loop index.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.18.66 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 7.3.7
Event History
Frequently Asked Questions
What condition is required to trigger the descriptor leak?
The allocation growth operation, krealloc(), must fail during the first iteration of gpiod_get_array(), after gpiod_get_index() has acquired the first GPIO descriptor. In that path, the descriptor count remains zero, so cleanup does not release the acquired descriptor.
How can I determine whether a kernel includes the fix?
Check whether the kernel source contains the gpiod_get_array() change that uses a dedicated loop index and increments descs->ndescs immediately after storing a retrieved descriptor. The provided stable references identify commits containing the fix.