From: "Pali Rohár" <pali@kernel.org>
To: Jason Cooper <jason@lakedaemon.net>,
Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
Rob Herring <robh@kernel.org>,
Bjorn Helgaas <bhelgaas@google.com>
Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] PCI: mvebu: Check if reset gpio is defined
Date: Mon, 10 Aug 2020 17:03:26 +0200 [thread overview]
Message-ID: <20200810150326.mrfcxnilpmib7u3m@pali> (raw)
In-Reply-To: <20200724132930.7206-1-pali@kernel.org>
On Friday 24 July 2020 15:29:30 Pali Rohár wrote:
> Reset gpio is optional and it does not have to be defined for all boards.
>
> So in mvebu_pcie_powerdown() like in mvebu_pcie_powerup() check that reset
> gpio is defined prior usage to prevent NULL pointer dereference.
>
> Signed-off-by: Pali Rohár <pali@kernel.org>
> ---
> drivers/pci/controller/pci-mvebu.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/pci/controller/pci-mvebu.c b/drivers/pci/controller/pci-mvebu.c
> index 153a64676bc9..58607cbe84c8 100644
> --- a/drivers/pci/controller/pci-mvebu.c
> +++ b/drivers/pci/controller/pci-mvebu.c
> @@ -947,7 +947,8 @@ static int mvebu_pcie_powerup(struct mvebu_pcie_port *port)
> */
> static void mvebu_pcie_powerdown(struct mvebu_pcie_port *port)
> {
> - gpiod_set_value_cansleep(port->reset_gpio, 1);
> + if (port->reset_gpio)
> + gpiod_set_value_cansleep(port->reset_gpio, 1);
Please drop this patch. I have realized that gpiod_set_value_cansleep()
calls VALIDATE_DESC_VOID() macro which returns from current running
function if passed pointer is NULL. So this patch is not needed as
gpiod_set_value_cansleep() may be called with NULL pointer.
>
> clk_disable_unprepare(port->clk);
> }
> --
> 2.20.1
>
prev parent reply other threads:[~2020-08-10 15:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-24 13:29 Pali Rohár
2020-08-10 15:03 ` Pali Rohár [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=20200810150326.mrfcxnilpmib7u3m@pali \
--to=pali@kernel.org \
--cc=bhelgaas@google.com \
--cc=jason@lakedaemon.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lorenzo.pieralisi@arm.com \
--cc=robh@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
all inboxes | Powered by JetHome®