summaryrefslogtreecommitdiff
path: root/rust/kernel
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2026-11-05 22:30:15 -0800
committerBartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>2026-11-09 10:25:03 +0100
commitb2a161687acdc297aa91fec7fa0966b5aecf0d16 (patch)
treedca56a99a7d880d54aea42a305bb0924f0443564 /rust/kernel
parentc62364eeac0f123478fca2f2d8e2424fdcd55032 (diff)
gpiolib: fix GPIO descriptor leak in gpiod_get_array()
In gpiod_get_array(), 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 gpiod_get_index(), but descs->ndescs is still 0. Consequently, gpiod_put_array() 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 array_info setup only executes for the first element (index 0), simplify the bitmap_set() calls to start at bit 0 for count bits instead of calculating offsets from the loop index. Fixes: bf9346f5d47b ("gpiolib: Identify arrays matching GPIO hardware") Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Link: https://patch.msgid.link/20261105-b4-gpiolib-free-v3-1-bb47ad58642d@gmail.com Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Diffstat (limited to 'rust/kernel')
0 files changed, 0 insertions, 0 deletions