Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1569387 > unrolled thread
| Started by | Shailendra Verma <shailendra.v@samsung.com> |
|---|---|
| First post | 2017-01-30 06:00 +0100 |
| Last post | 2017-01-30 20:10 +0100 |
| 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] Arch: arm: plat-pxa - Fix possible NULL derefrence. Shailendra Verma <shailendra.v@samsung.com> - 2017-01-30 06:00 +0100
Re: [PATCH] Arch: arm: plat-pxa - Fix possible NULL derefrence. Russell King - ARM Linux <linux@armlinux.org.uk> - 2017-01-30 20:10 +0100
| From | Shailendra Verma <shailendra.v@samsung.com> |
|---|---|
| Date | 2017-01-30 06:00 +0100 |
| Subject | [PATCH] Arch: arm: plat-pxa - Fix possible NULL derefrence. |
| Message-ID | <t5cem-804-11@gated-at.bofh.it> |
of_match_device could return NULL, and so can cause a NULL
pointer dereference later.
Signed-off-by: Shailendra Verma <shailendra.v@samsung.com>
---
arch/arm/plat-pxa/ssp.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/arch/arm/plat-pxa/ssp.c b/arch/arm/plat-pxa/ssp.c
index ba13f79..7d1cd51 100644
--- a/arch/arm/plat-pxa/ssp.c
+++ b/arch/arm/plat-pxa/ssp.c
@@ -204,6 +204,10 @@ static int pxa_ssp_probe(struct platform_device *pdev)
if (dev->of_node) {
const struct of_device_id *id =
of_match_device(of_match_ptr(pxa_ssp_of_ids), dev);
+ if (!id) {
+ dev_err(dev, "Error: No device match found\n");
+ return -ENODEV;
+ }
ssp->type = (int) id->data;
} else {
const struct platform_device_id *id =
--
1.7.9.5
[toc] | [next] | [standalone]
| From | Russell King - ARM Linux <linux@armlinux.org.uk> |
|---|---|
| Date | 2017-01-30 20:10 +0100 |
| Message-ID | <t5puW-7L5-21@gated-at.bofh.it> |
| In reply to | #1569387 |
On Mon, Jan 30, 2017 at 10:28:31AM +0530, Shailendra Verma wrote:
> of_match_device could return NULL, and so can cause a NULL
> pointer dereference later.
Please explain how this can happen.
The driver is matched to the device via the driver model looking up
the compatible string in the match table:
.of_match_table = of_match_ptr(pxa_ssp_of_ids),
It then calls the probe function, which notices that there's a DT
node pointer, and the driver looks the device up in the very same
table.
If the driver model found a match and then the device driver didn't
for the very same device, something really bad went wrong.
So, if you want to add something:
if (WARN_ON(!id))
return -ENODEV;
should be about it, since it's something we expect to never encounter.
--
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web