From: Linus Walleij <linus.walleij@linaro.org>
To: Jia-Ju Bai <baijiaju1990@gmail.com>
Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>,
"open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/2 v2] gpio: gpio-grgpio: fix possible sleep-in-atomic-context bugs in grgpio_remove()
Date: Tue, 7 Jan 2020 09:59:22 +0100 [thread overview]
Message-ID: <CACRpkdZEpMDbrHxkaNLiqqaeVKTW3y6k6EpZA8z6nf-9sRF3qQ@mail.gmail.com> (raw)
In-Reply-To: <20191219131459.18640-1-baijiaju1990@gmail.com>
On Thu, Dec 19, 2019 at 2:15 PM Jia-Ju Bai <baijiaju1990@gmail.com> wrote:
> drivers/gpio/gpiolib-sysfs.c, 796:
> mutex_lock in gpiochip_sysfs_unregister
> drivers/gpio/gpiolib.c, 1455:
> gpiochip_sysfs_unregister in gpiochip_remove
> drivers/gpio/gpio-grgpio.c, 460:
> gpiochip_remove in grgpio_remove
> drivers/gpio/gpio-grgpio.c, 449:
> _raw_spin_lock_irqsave in grgpio_remove
>
> kernel/irq/irqdomain.c, 243:
> mutex_lock in irq_domain_remove
> drivers/gpio/gpio-grgpio.c, 463:
> irq_domain_remove in grgpio_remove
> drivers/gpio/gpio-grgpio.c, 449:
> _raw_spin_lock_irqsave in grgpio_remove
>
> mutex_lock() can sleep at runtime.
>
> To fix these bugs, the lock is dropped in grgpio_remove(), because there
> is no need for locking in remove() callbacks.
>
> These bugs are found by a static analysis tool STCheck written by
> myself.
>
> Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
> ---
> v2:
> * Drop the lock instead of moving the calls to lock functions.
> Thank Bartosz for good advice.
Looks good to me, patch applied!
Yours,
Linus Walleij
prev parent reply other threads:[~2020-01-07 8:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-19 13:14 [PATCH 1/2 v2] gpio: gpio-grgpio: fix possible sleep-in-atomic-context bugs in grgpio_remove() Jia-Ju Bai
2020-01-07 8:59 ` Linus Walleij [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CACRpkdZEpMDbrHxkaNLiqqaeVKTW3y6k6EpZA8z6nf-9sRF3qQ@mail.gmail.com \
--to=linus.walleij@linaro.org \
--cc=baijiaju1990@gmail.com \
--cc=bgolaszewski@baylibre.com \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).