[PATCH v2] gpio: gpiolib: clear the array_info's memory space

From: Yan Wang
Date: Sun Apr 23 2023 - 10:00:16 EST


if hardware number different to array index,it needs to clear to points
memory space if the array_info have been assigned a value.

Reported-by: kernel test robot <lkp@xxxxxxxxx>
Link: https://lore.kernel.org/oe-kbuild-all/202304232146.7M89pwCz-lkp@xxxxxxxxx/
Signed-off-by: Yan Wang <rk.code@xxxxxxxxxxx>
---
v1->v2: fixed building warning
---
drivers/gpio/gpiolib.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 04fb05df805b..8b2a8db44b54 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -4359,6 +4359,8 @@ struct gpio_descs *__must_check gpiod_get_array(struct device *dev,
* hardware number is different from its array index.
*/
if (bitmap_full(array_info->get_mask, descs->ndescs)) {
+ /*clear descs->info*/
+ memset(array_info, 0, sizeof(struct gpio_array));
array_info = NULL;
} else {
__clear_bit(descs->ndescs,
--
2.17.1