From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Mike Qiu <qiudayu@linux.vnet.ibm.com>
Cc: linux-pci@vger.kernel.org, tglx@linutronix.de
Subject: Re: [PATCH] PowerNV/PCI: Fix NULL PCI controller
Date: Mon, 22 Apr 2013 16:36:17 +1000 [thread overview]
Message-ID: <1366612577.2723.21.camel@pasglop> (raw)
In-Reply-To: <1366611236-1811-1-git-send-email-qiudayu@linux.vnet.ibm.com>
On Mon, 2013-04-22 at 02:13 -0400, Mike Qiu wrote:
> In pnv_pci_read_config() or pnv_pci_write_config(), we never check if
> the PCI controller is valid before converting that into platform
> dependent one, this is very dangerous.
>
> To avoid this potential risks, the patch check PCI controller first
> before use it.
I don't think there's any remote possibility of that happening, is
there ?
If it does, maybe it warrants a WARN_ON...
Ben.
> Signed-off-by: Mike Qiu <qiudayu@linux.vnet.ibm.com>
> ---
> arch/powerpc/platforms/powernv/pci.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/arch/powerpc/platforms/powernv/pci.c b/arch/powerpc/platforms/powernv/pci.c
> index b8b8e0b..e7b7f1a 100644
> --- a/arch/powerpc/platforms/powernv/pci.c
> +++ b/arch/powerpc/platforms/powernv/pci.c
> @@ -286,11 +286,11 @@ static int pnv_pci_read_config(struct pci_bus *bus,
> int where, int size, u32 *val)
> {
> struct pci_controller *hose = pci_bus_to_host(bus);
> - struct pnv_phb *phb = hose->private_data;
> + struct pnv_phb *phb = hose ? hose->private_data : NULL;
> u32 bdfn = (((uint64_t)bus->number) << 8) | devfn;
> s64 rc;
>
> - if (hose == NULL)
> + if (!phb)
> return PCIBIOS_DEVICE_NOT_FOUND;
>
> switch (size) {
> @@ -330,10 +330,10 @@ static int pnv_pci_write_config(struct pci_bus *bus,
> int where, int size, u32 val)
> {
> struct pci_controller *hose = pci_bus_to_host(bus);
> - struct pnv_phb *phb = hose->private_data;
> + struct pnv_phb *phb = hose ? hose->private_data : NULL;
> u32 bdfn = (((uint64_t)bus->number) << 8) | devfn;
>
> - if (hose == NULL)
> + if (!phb)
> return PCIBIOS_DEVICE_NOT_FOUND;
>
> cfg_dbg("pnv_pci_write_config bus: %x devfn: %x +%x/%x -> %08x\n",
next prev parent reply other threads:[~2013-04-22 6:36 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-22 6:13 [PATCH] PowerNV/PCI: Fix NULL PCI controller Mike Qiu
2013-04-22 6:15 ` Mike Qiu
2013-04-22 6:36 ` Benjamin Herrenschmidt [this message]
2013-04-22 7:41 ` Mike Qiu
2013-04-22 8:04 ` Benjamin Herrenschmidt
2013-04-22 9:44 ` Mike Qiu
2013-04-22 17:35 ` Bjorn Helgaas
2013-04-23 1:46 ` Mike Qiu
2013-04-23 1:49 ` Benjamin Herrenschmidt
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=1366612577.2723.21.camel@pasglop \
--to=benh@kernel.crashing.org \
--cc=linux-pci@vger.kernel.org \
--cc=qiudayu@linux.vnet.ibm.com \
--cc=tglx@linutronix.de \
/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