Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1615046 > unrolled thread
| Started by | Alistair Popple <alistair@popple.id.au> |
|---|---|
| First post | 2017-04-03 12:00 +0200 |
| Last post | 2017-04-06 15:10 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH v2 2/3] powerpc/powernv: Add sanity checks to pnv_pci_get_{gpu|npu}_dev Alistair Popple <alistair@popple.id.au> - 2017-04-03 12:00 +0200
Re: [v2, 2/3] powerpc/powernv: Add sanity checks to pnv_pci_get_{gpu|npu}_dev Michael Ellerman <patch-notifications@ellerman.id.au> - 2017-04-06 15:10 +0200
| From | Alistair Popple <alistair@popple.id.au> |
|---|---|
| Date | 2017-04-03 12:00 +0200 |
| Subject | [PATCH v2 2/3] powerpc/powernv: Add sanity checks to pnv_pci_get_{gpu|npu}_dev |
| Message-ID | <ts6We-5aL-13@gated-at.bofh.it> |
The pnv_pci_get_{gpu|npu}_dev functions are used to find associations
between nvlink PCIe devices and standard PCIe devices. However they
lacked basic sanity checking which results in NULL pointer
dereferencing if they are incorrect called can be harder to spot than
an explicit WARN_ON.
Signed-off-by: Alistair Popple <alistair@popple.id.au>
---
arch/powerpc/platforms/powernv/npu-dma.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/arch/powerpc/platforms/powernv/npu-dma.c b/arch/powerpc/platforms/powernv/npu-dma.c
index 1c383f3..050bd5d 100644
--- a/arch/powerpc/platforms/powernv/npu-dma.c
+++ b/arch/powerpc/platforms/powernv/npu-dma.c
@@ -37,6 +37,12 @@ struct pci_dev *pnv_pci_get_gpu_dev(struct pci_dev *npdev)
struct device_node *dn;
struct pci_dev *gpdev;
+ if (WARN_ON(!npdev))
+ return NULL;
+
+ if (WARN_ON(!npdev->dev.of_node))
+ return NULL;
+
/* Get assoicated PCI device */
dn = of_parse_phandle(npdev->dev.of_node, "ibm,gpu", 0);
if (!dn)
@@ -55,6 +61,12 @@ struct pci_dev *pnv_pci_get_npu_dev(struct pci_dev *gpdev, int index)
struct device_node *dn;
struct pci_dev *npdev;
+ if (WARN_ON(!gpdev))
+ return NULL;
+
+ if (WARN_ON(!gpdev->dev.of_node))
+ return NULL;
+
/* Get assoicated PCI device */
dn = of_parse_phandle(gpdev->dev.of_node, "ibm,npu", index);
if (!dn)
--
2.1.4
[toc] | [next] | [standalone]
| From | Michael Ellerman <patch-notifications@ellerman.id.au> |
|---|---|
| Date | 2017-04-06 15:10 +0200 |
| Subject | Re: [v2, 2/3] powerpc/powernv: Add sanity checks to pnv_pci_get_{gpu|npu}_dev |
| Message-ID | <ttfkK-ux-17@gated-at.bofh.it> |
| In reply to | #1615046 |
On Mon, 2017-04-03 at 09:51:43 UTC, Alistair Popple wrote:
> The pnv_pci_get_{gpu|npu}_dev functions are used to find associations
> between nvlink PCIe devices and standard PCIe devices. However they
> lacked basic sanity checking which results in NULL pointer
> dereferencing if they are incorrect called can be harder to spot than
> an explicit WARN_ON.
>
> Signed-off-by: Alistair Popple <alistair@popple.id.au>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/4c3b89effc281704d5395282c800c4
cheers
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web