diff mbox series

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

Message ID KL1PR01MB54489B7A3D9D02D242B4BDA1E6669@KL1PR01MB5448.apcprd01.prod.exchangelabs.com
State New
Headers show
Series [v1] gpio: gpiolib: clear the array_info's memory space | expand

Commit Message

Yan Wang April 23, 2023, 11:03 a.m. UTC
if hardware number different to array index,it needs to clear to points
memory space if the array_info have been assigned a value.

Signed-off-by: Yan Wang <rk.code@outlook.com>
---
 drivers/gpio/gpiolib.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 04fb05df805b..cdaffcdd45b2 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -4340,8 +4340,11 @@  struct gpio_descs *__must_check gpiod_get_array(struct device *dev,
 		}
 
 		/* If there is no cache for fast bitmap processing path, continue */
-		if (!array_info)
+		if (!array_info) {
+			/*clear descs->info*/
+			memset(array_info, 0, sizeof(struct gpio_array));
 			continue;
+		}
 
 		/* Unmark array members which don't belong to the 'fast' chip */
 		if (array_info->chip != gc) {