diff mbox series

[v1,1/3] gpiolib: acpi: Add missing memset(0) to acpi_get_gpiod_from_data()

Message ID 20231019173457.2445119-2-andriy.shevchenko@linux.intel.com
State New
Headers show
Series gpiolib: acpi: More fixes to the consolidation rework | expand

Commit Message

Andy Shevchenko Oct. 19, 2023, 5:34 p.m. UTC
When refactoring the acpi_get_gpiod_from_data() the change missed
cleaning up the variable on stack. Add missing memset().

Reported-by: Ferry Toth <ftoth@exalondelft.nl>
Fixes: 16ba046e86e9 ("gpiolib: acpi: teach acpi_find_gpio() to handle data-only nodes")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/gpio/gpiolib-acpi.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Dmitry Torokhov Oct. 19, 2023, 7:20 p.m. UTC | #1
On Thu, Oct 19, 2023 at 08:34:55PM +0300, Andy Shevchenko wrote:
> When refactoring the acpi_get_gpiod_from_data() the change missed
> cleaning up the variable on stack. Add missing memset().
> 
> Reported-by: Ferry Toth <ftoth@exalondelft.nl>
> Fixes: 16ba046e86e9 ("gpiolib: acpi: teach acpi_find_gpio() to handle data-only nodes")
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Although I think it would be better to change
acpi_gpio_resource_lookup() to take an index and return a gpiod
descriptor and have a local copy of the lookup structure. 

> ---
>  drivers/gpio/gpiolib-acpi.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
> index fbda452fb4d6..51e41676de0b 100644
> --- a/drivers/gpio/gpiolib-acpi.c
> +++ b/drivers/gpio/gpiolib-acpi.c
> @@ -951,6 +951,7 @@ static struct gpio_desc *acpi_get_gpiod_from_data(struct fwnode_handle *fwnode,
>  	if (!propname)
>  		return ERR_PTR(-EINVAL);
>  
> +	memset(&lookup, 0, sizeof(lookup));
>  	lookup.index = index;
>  
>  	ret = acpi_gpio_property_lookup(fwnode, propname, index, &lookup);
> -- 
> 2.40.0.1.gaa8946217a0b
> 

Thanks.
Bartosz Golaszewski Oct. 20, 2023, 9:25 a.m. UTC | #2
On Thu, Oct 19, 2023 at 9:20 PM Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
>
> On Thu, Oct 19, 2023 at 08:34:55PM +0300, Andy Shevchenko wrote:
> > When refactoring the acpi_get_gpiod_from_data() the change missed
> > cleaning up the variable on stack. Add missing memset().
> >
> > Reported-by: Ferry Toth <ftoth@exalondelft.nl>
> > Fixes: 16ba046e86e9 ("gpiolib: acpi: teach acpi_find_gpio() to handle data-only nodes")
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>
> Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
>
> Although I think it would be better to change
> acpi_gpio_resource_lookup() to take an index and return a gpiod
> descriptor and have a local copy of the lookup structure.
>

I queued it for fixes as this is a bug, we can improve it later.

Bart

> > ---
> >  drivers/gpio/gpiolib-acpi.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
> > index fbda452fb4d6..51e41676de0b 100644
> > --- a/drivers/gpio/gpiolib-acpi.c
> > +++ b/drivers/gpio/gpiolib-acpi.c
> > @@ -951,6 +951,7 @@ static struct gpio_desc *acpi_get_gpiod_from_data(struct fwnode_handle *fwnode,
> >       if (!propname)
> >               return ERR_PTR(-EINVAL);
> >
> > +     memset(&lookup, 0, sizeof(lookup));
> >       lookup.index = index;
> >
> >       ret = acpi_gpio_property_lookup(fwnode, propname, index, &lookup);
> > --
> > 2.40.0.1.gaa8946217a0b
> >
>
> Thanks.
>
> --
> Dmitry
diff mbox series

Patch

diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index fbda452fb4d6..51e41676de0b 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -951,6 +951,7 @@  static struct gpio_desc *acpi_get_gpiod_from_data(struct fwnode_handle *fwnode,
 	if (!propname)
 		return ERR_PTR(-EINVAL);
 
+	memset(&lookup, 0, sizeof(lookup));
 	lookup.index = index;
 
 	ret = acpi_gpio_property_lookup(fwnode, propname, index, &lookup);