Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1569418 > unrolled thread
| Started by | Shailendra Verma <shailendra.v@samsung.com> |
|---|---|
| First post | 2017-01-30 07:10 +0100 |
| Last post | 2017-01-30 16:40 +0100 |
| Articles | 3 — 3 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] Pinctrl: mvebu - Fix possible NULL derefrence. Shailendra Verma <shailendra.v@samsung.com> - 2017-01-30 07:10 +0100
Re: [PATCH] Pinctrl: mvebu - Fix possible NULL derefrence. Thomas Petazzoni <thomas.petazzoni@free-electrons.com> - 2017-01-30 09:40 +0100
Re: [PATCH] Pinctrl: mvebu - Fix possible NULL derefrence. Linus Walleij <linus.walleij@linaro.org> - 2017-01-30 16:40 +0100
| From | Shailendra Verma <shailendra.v@samsung.com> |
|---|---|
| Date | 2017-01-30 07:10 +0100 |
| Subject | [PATCH] Pinctrl: mvebu - Fix possible NULL derefrence. |
| Message-ID | <t5dk5-se-3@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>
---
drivers/pinctrl/mvebu/pinctrl-dove.c | 4 ++++
drivers/pinctrl/mvebu/pinctrl-kirkwood.c | 4 ++++
drivers/pinctrl/mvebu/pinctrl-orion.c | 4 ++++
3 files changed, 12 insertions(+)
diff --git a/drivers/pinctrl/mvebu/pinctrl-dove.c b/drivers/pinctrl/mvebu/pinctrl-dove.c
index f93ae0d..f9fe6d4 100644
--- a/drivers/pinctrl/mvebu/pinctrl-dove.c
+++ b/drivers/pinctrl/mvebu/pinctrl-dove.c
@@ -769,6 +769,10 @@ static int dove_pinctrl_probe(struct platform_device *pdev)
struct resource fb_res;
const struct of_device_id *match =
of_match_device(dove_pinctrl_of_match, &pdev->dev);
+ if (!match) {
+ dev_err(&pdev->dev, "Error: No device match found\n");
+ return -ENODEV;
+ }
pdev->dev.platform_data = (void *)match->data;
/*
diff --git a/drivers/pinctrl/mvebu/pinctrl-kirkwood.c b/drivers/pinctrl/mvebu/pinctrl-kirkwood.c
index 5f89c26..75efb83 100644
--- a/drivers/pinctrl/mvebu/pinctrl-kirkwood.c
+++ b/drivers/pinctrl/mvebu/pinctrl-kirkwood.c
@@ -472,6 +472,10 @@ static int kirkwood_pinctrl_probe(struct platform_device *pdev)
struct resource *res;
const struct of_device_id *match =
of_match_device(kirkwood_pinctrl_of_match, &pdev->dev);
+ if (!match) {
+ dev_err(&pdev->dev, "Error: No device match found\n");
+ return -ENODEV;
+ }
pdev->dev.platform_data = (void *)match->data;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
diff --git a/drivers/pinctrl/mvebu/pinctrl-orion.c b/drivers/pinctrl/mvebu/pinctrl-orion.c
index 84e1441..559ac32 100644
--- a/drivers/pinctrl/mvebu/pinctrl-orion.c
+++ b/drivers/pinctrl/mvebu/pinctrl-orion.c
@@ -225,6 +225,10 @@ static int orion_pinctrl_probe(struct platform_device *pdev)
of_match_device(orion_pinctrl_of_match, &pdev->dev);
struct resource *res;
+ if (!match) {
+ dev_err(&pdev->dev, "Error: No device match found\n");
+ return -ENODEV;
+ }
pdev->dev.platform_data = (void*)match->data;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
--
1.7.9.5
[toc] | [next] | [standalone]
| From | Thomas Petazzoni <thomas.petazzoni@free-electrons.com> |
|---|---|
| Date | 2017-01-30 09:40 +0100 |
| Message-ID | <t5fFf-1Jp-1@gated-at.bofh.it> |
| In reply to | #1569418 |
Hello, On Mon, 30 Jan 2017 10:21:43 +0530, Shailendra Verma wrote: > of_match_device could return NULL, and so can cause a NULL > pointer dereference later. > > Signed-off-by: Shailendra Verma <shailendra.v@samsung.com> In practice, I don't see how of_match_device() can return NULL here. Indeed, those drivers only support Device Tree based probing, so of_match_device() will always return a non-NULL value. Thomas -- Thomas Petazzoni, CTO, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
[toc] | [prev] | [next] | [standalone]
| From | Linus Walleij <linus.walleij@linaro.org> |
|---|---|
| Date | 2017-01-30 16:40 +0100 |
| Message-ID | <t5mdI-5F2-33@gated-at.bofh.it> |
| In reply to | #1569464 |
On Mon, Jan 30, 2017 at 9:24 AM, Thomas Petazzoni <thomas.petazzoni@free-electrons.com> wrote: > On Mon, 30 Jan 2017 10:21:43 +0530, Shailendra Verma wrote: >> of_match_device could return NULL, and so can cause a NULL >> pointer dereference later. >> >> Signed-off-by: Shailendra Verma <shailendra.v@samsung.com> > > In practice, I don't see how of_match_device() can return NULL here. > Indeed, those drivers only support Device Tree based probing, so > of_match_device() will always return a non-NULL value. OK you're right, this is too overly cautious. Saliendra, sorry but I have to drop these patches. Yours, Linus Walleij
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web