On Mon, Jun 03, 2019 at 10:33:31AM +0200, Stefan Roese wrote:
> This patch adds a check for the GPIOs property existence, before the
> GPIO is requested. This fixes an issue seen when the 8250 mctrl_gpio
> support is added (2nd patch in this patch series) on x86 platforms using
> ACPI.

>       for (i = 0; i < UART_GPIO_MAX; i++) {
>               enum gpiod_flags flags;
> +             char *gpio_str;
> +
> +             /* Check if GPIO property exists and continue if not */
> +             gpio_str = kasprintf(GFP_KERNEL, "%s-gpios",
> +                                  mctrl_gpios_desc[i].name);
> +             if (!device_property_present(dev, gpio_str)) {
> +                     kfree(gpio_str);
> +                     continue;
> +             }
> +             kfree(gpio_str);

Can we rather do something like

        bool present;


        ... = kasprintf(...);
// (1)
        present = device_property_present(...);
        kfree(...);
        if (!present)
                continue;

?

On top of this, if gpio_str is NULL, we will have KABOOM.

Something like

        if (!gpio_str)
                continue;

in (1).

>  
>               if (mctrl_gpios_desc[i].dir_out)
>                       flags = GPIOD_OUT_LOW;

-- 
With Best Regards,
Andy Shevchenko


Reply via email to