* [PATCH 1/1] PCI: check return value of pci_find_ext_capability
@ 2017-04-23 14:00 Pan Bian
2017-04-24 10:36 ` Mika Westerberg
0 siblings, 1 reply; 3+ messages in thread
From: Pan Bian @ 2017-04-23 14:00 UTC (permalink / raw)
To: Bjorn Helgaas, Lukas Wunner, Keith Busch, Rafael J. Wysocki,
Mika Westerberg, linux-pci
Cc: linux-kernel, Pan Bian
From: Pan Bian <bianpan2016@163.com>
Function pci_find_ext_capability() will returns 0 on failure, and its
return value should be checked before it is used. However, in function
pcie_port_enable_msix(), its return value is not checked. This patch
adds the check.
Signed-off-by: Pan Bian <bianpan2016@163.com>
---
drivers/pci/pcie/portdrv_core.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c
index cea504f..001951d 100644
--- a/drivers/pci/pcie/portdrv_core.c
+++ b/drivers/pci/pcie/portdrv_core.c
@@ -103,6 +103,8 @@ static int pcie_port_enable_msix(struct pci_dev *dev, int *irqs, int mask)
* interrupt message."
*/
pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR);
+ if (!pos)
+ goto out_free_irqs;
pci_read_config_dword(dev, pos + PCI_ERR_ROOT_STATUS, ®32);
entry = reg32 >> 27;
if (entry >= nr_entries)
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] PCI: check return value of pci_find_ext_capability
2017-04-23 14:00 [PATCH 1/1] PCI: check return value of pci_find_ext_capability Pan Bian
@ 2017-04-24 10:36 ` Mika Westerberg
2017-04-25 19:31 ` Bjorn Helgaas
0 siblings, 1 reply; 3+ messages in thread
From: Mika Westerberg @ 2017-04-24 10:36 UTC (permalink / raw)
To: Pan Bian
Cc: Bjorn Helgaas, Lukas Wunner, Keith Busch, Rafael J. Wysocki,
linux-pci, linux-kernel, Pan Bian
On Sun, Apr 23, 2017 at 10:00:20PM +0800, Pan Bian wrote:
> From: Pan Bian <bianpan2016@163.com>
>
> Function pci_find_ext_capability() will returns 0 on failure, and its
> return value should be checked before it is used. However, in function
> pcie_port_enable_msix(), its return value is not checked. This patch
> adds the check.
>
> Signed-off-by: Pan Bian <bianpan2016@163.com>
> ---
> drivers/pci/pcie/portdrv_core.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c
> index cea504f..001951d 100644
> --- a/drivers/pci/pcie/portdrv_core.c
> +++ b/drivers/pci/pcie/portdrv_core.c
> @@ -103,6 +103,8 @@ static int pcie_port_enable_msix(struct pci_dev *dev, int *irqs, int mask)
> * interrupt message."
> */
> pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR);
> + if (!pos)
> + goto out_free_irqs;
I don't think this can happen because get_port_device_capability() will
enumerate this capability and only if it exists, set PCIE_PORT_SERVICE_AER.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] PCI: check return value of pci_find_ext_capability
2017-04-24 10:36 ` Mika Westerberg
@ 2017-04-25 19:31 ` Bjorn Helgaas
0 siblings, 0 replies; 3+ messages in thread
From: Bjorn Helgaas @ 2017-04-25 19:31 UTC (permalink / raw)
To: Mika Westerberg
Cc: Pan Bian, Bjorn Helgaas, Lukas Wunner, Keith Busch,
Rafael J. Wysocki, linux-pci, linux-kernel, Pan Bian
On Mon, Apr 24, 2017 at 01:36:58PM +0300, Mika Westerberg wrote:
> On Sun, Apr 23, 2017 at 10:00:20PM +0800, Pan Bian wrote:
> > From: Pan Bian <bianpan2016@163.com>
> >
> > Function pci_find_ext_capability() will returns 0 on failure, and its
> > return value should be checked before it is used. However, in function
> > pcie_port_enable_msix(), its return value is not checked. This patch
> > adds the check.
> >
> > Signed-off-by: Pan Bian <bianpan2016@163.com>
> > ---
> > drivers/pci/pcie/portdrv_core.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c
> > index cea504f..001951d 100644
> > --- a/drivers/pci/pcie/portdrv_core.c
> > +++ b/drivers/pci/pcie/portdrv_core.c
> > @@ -103,6 +103,8 @@ static int pcie_port_enable_msix(struct pci_dev *dev, int *irqs, int mask)
> > * interrupt message."
> > */
> > pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR);
> > + if (!pos)
> > + goto out_free_irqs;
>
> I don't think this can happen because get_port_device_capability() will
> enumerate this capability and only if it exists, set PCIE_PORT_SERVICE_AER.
The path is more complicated than I'd like, but I think you're right.
We should also be able to use dev->aer_cap here instead of looking it
up again.
Bjorn
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-04-25 19:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-23 14:00 [PATCH 1/1] PCI: check return value of pci_find_ext_capability Pan Bian
2017-04-24 10:36 ` Mika Westerberg
2017-04-25 19:31 ` Bjorn Helgaas
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).