Re: [bug report] gpiolib: remove gpiochip_is_requested()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Dec 12, 2023 at 10:20 AM Dan Carpenter <dan.carpenter@xxxxxxxxxx> wrote:
>
> Hello Bartosz Golaszewski,
>
> The patch f8d05e276b45: "gpiolib: remove gpiochip_is_requested()"
> from Dec 4, 2023 (linux-next), leads to the following Smatch static
> checker warning:
>
>         drivers/gpio/gpiolib.c:2402 gpiochip_dup_line_label()
>         warn: sleeping in atomic context
>
> drivers/gpio/gpiolib.c
>     2392
>     2393         desc = gpiochip_get_desc(gc, offset);
>     2394         if (IS_ERR(desc))
>     2395                 return NULL;
>     2396
>     2397         guard(spinlock_irqsave)(&gpio_lock);
>                        ^^^^^^^^^^^^^^^^
> This takes the lock until the end of scope (the end of the function in
> this case).
>
>
>     2398
>     2399         if (!test_bit(FLAG_REQUESTED, &desc->flags))
>     2400                 return NULL;
>     2401
> --> 2402         label = kstrdup(desc->label, GFP_KERNEL);
>                                               ^^^^^^^^^^
> Can't do GFP_KERNEL allocations while holding a spinlock.  Testing with
> CONFIG_DEBUG_ATOMIC_SLEEP will warn about this.
>
>     2403         if (!label)
>     2404                 return ERR_PTR(-ENOMEM);
>     2405
>     2406         return label;
>     2407 }
>
> regards,
> dan carpenter
>

Thanks Dan,

I sent out a fix[1].

Bart

[1] https://lore.kernel.org/linux-gpio/20231212105501.16347-1-brgl@xxxxxxxx/T/#u





[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux