From: Marc Zyngier <maz@kernel.org>
To: Dongliang Mu <dzm91@hust.edu.cn>
Cc: Linus Walleij <linus.walleij@linaro.org>,
Bartosz Golaszewski <brgl@bgdev.pl>,
Dongliang Mu <mudongliangabcd@gmail.com>,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] gpio: tpmx86: fix uninitialized variable girq
Date: Wed, 14 Sep 2022 08:35:22 +0100 [thread overview]
Message-ID: <87zgf2l879.wl-maz@kernel.org> (raw)
In-Reply-To: <20220914051842.69776-1-dzm91@hust.edu.cn>
On Wed, 14 Sep 2022 06:18:42 +0100,
Dongliang Mu <dzm91@hust.edu.cn> wrote:
>
> From: Dongliang Mu <mudongliangabcd@gmail.com>
>
> The commit 924610607f19 ("gpio: tpmx86: Move PM device over to
> irq domain") adds a dereference of girq that may be uninitialized.
>
> Fix this by initializing girq and checking irq before invoking
> irq_domain_set_pm_device.
>
> Fixes: 924610607f19 ("gpio: tpmx86: Move PM device over to irq domain")
> Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
> ---
> drivers/gpio/gpio-tqmx86.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpio/gpio-tqmx86.c b/drivers/gpio/gpio-tqmx86.c
> index fa4bc7481f9a..bdef182c11c2 100644
> --- a/drivers/gpio/gpio-tqmx86.c
> +++ b/drivers/gpio/gpio-tqmx86.c
> @@ -231,7 +231,7 @@ static int tqmx86_gpio_probe(struct platform_device *pdev)
> struct device *dev = &pdev->dev;
> struct tqmx86_gpio_data *gpio;
> struct gpio_chip *chip;
> - struct gpio_irq_chip *girq;
> + struct gpio_irq_chip *girq = NULL;
> void __iomem *io_base;
> struct resource *res;
> int ret, irq;
> @@ -315,7 +315,9 @@ static int tqmx86_gpio_probe(struct platform_device *pdev)
> goto out_pm_dis;
> }
>
> - irq_domain_set_pm_device(girq->domain, dev);
> + if (girq) {
> + irq_domain_set_pm_device(girq->domain, dev);
> + }
>
> dev_info(dev, "GPIO functionality initialized with %d pins\n",
> chip->ngpio);
I wonder if a better fix wouldn't be to directly hoist the
irq_domain_set_pm_device() call into the 'if (irq > 0)' block.
Thanks,
M.
--
Without deviation from the norm, progress is not possible.
next prev parent reply other threads:[~2022-09-14 7:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-14 5:18 [PATCH] gpio: tpmx86: fix uninitialized variable girq Dongliang Mu
2022-09-14 7:35 ` Marc Zyngier [this message]
2022-09-15 6:08 ` Dongliang Mu
2022-09-16 7:56 ` Marc Zyngier
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=87zgf2l879.wl-maz@kernel.org \
--to=maz@kernel.org \
--cc=brgl@bgdev.pl \
--cc=dzm91@hust.edu.cn \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mudongliangabcd@gmail.com \
/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