[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CACRpkdbDNfrUZiVbDRx9EQWByfzXHtA3ZO+dUXvEK5RzYYYgUw@mail.gmail.com>
Date: Mon, 15 May 2023 09:25:53 +0200
From: Linus Walleij <linus.walleij@...aro.org>
To: Yan Wang <rk.code@...look.com>
Cc: brgl@...ev.pl,
"open list:GPIO SUBSYSTEM" <linux-gpio@...r.kernel.org>,
open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2] gpio: gpiolib: clear the array_info's memory space
> @@ -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;
This is not the right solution.
The array_info points beyond descs and descs have be krealloc:ed
to fit the array info.
The right solution is not to fill that memory with zeroes, but to krealloc
back to the size that descs had before we did this resizing to begin
with.
Possibly the condition should be detected *before* we start to krealloc()
so we can avoid all the krealloc():ing.
If the actual issue cannot be fixed I think it is no better or worse to just
leave the code as it is, we are just zeroing some unused memory.
Yours,
Linus Walleij
Powered by blists - more mailing lists