Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1267693 > unrolled thread
| Started by | LABBE Corentin <clabbe.montjoie@gmail.com> |
|---|---|
| First post | 2015-11-12 08:50 +0100 |
| Last post | 2015-11-12 15:50 +0100 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH] pwm: sun4i: fix a possible NULL dereference LABBE Corentin <clabbe.montjoie@gmail.com> - 2015-11-12 08:50 +0100
Re: [PATCH] pwm: sun4i: fix a possible NULL dereference Thierry Reding <thierry.reding@gmail.com> - 2015-11-12 13:40 +0100
Re: [PATCH] pwm: sun4i: fix a possible NULL dereference Alexandre Belloni <alexandre.belloni@free-electrons.com> - 2015-11-12 15:50 +0100
| From | LABBE Corentin <clabbe.montjoie@gmail.com> |
|---|---|
| Date | 2015-11-12 08:50 +0100 |
| Subject | [PATCH] pwm: sun4i: fix a possible NULL dereference |
| Message-ID | <qtUNQ-5ZA-25@gated-at.bofh.it> |
of_match_device could return NULL, and so cause a NULL pointer dereference later. Reported-by: coverity (CID 1324139) Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com> --- drivers/pwm/pwm-sun4i.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/pwm/pwm-sun4i.c b/drivers/pwm/pwm-sun4i.c index cd9dde5..3011fcc 100644 --- a/drivers/pwm/pwm-sun4i.c +++ b/drivers/pwm/pwm-sun4i.c @@ -291,6 +291,8 @@ static int sun4i_pwm_probe(struct platform_device *pdev) const struct of_device_id *match; match = of_match_device(sun4i_pwm_dt_ids, &pdev->dev); + if (!match) + return -ENODEV; pwm = devm_kzalloc(&pdev->dev, sizeof(*pwm), GFP_KERNEL); if (!pwm) -- 2.4.10 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Thierry Reding <thierry.reding@gmail.com> |
|---|---|
| Date | 2015-11-12 13:40 +0100 |
| Message-ID | <qtZkt-rS-15@gated-at.bofh.it> |
| In reply to | #1267693 |
[Multipart message — attachments visible in raw view] — view raw
On Thu, Nov 12, 2015 at 08:42:12AM +0100, LABBE Corentin wrote: > of_match_device could return NULL, and so cause a NULL pointer > dereference later. > > Reported-by: coverity (CID 1324139) > Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com> > --- > drivers/pwm/pwm-sun4i.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/pwm/pwm-sun4i.c b/drivers/pwm/pwm-sun4i.c > index cd9dde5..3011fcc 100644 > --- a/drivers/pwm/pwm-sun4i.c > +++ b/drivers/pwm/pwm-sun4i.c > @@ -291,6 +291,8 @@ static int sun4i_pwm_probe(struct platform_device *pdev) > const struct of_device_id *match; > > match = of_match_device(sun4i_pwm_dt_ids, &pdev->dev); > + if (!match) > + return -ENODEV; I explained this in a reply to another similar patch, but that was a different audience, so here goes again: the driver core will use the same device ID table to match on the driver, so the case where NULL would be returned is the same case in which sun4i_pwm_probe() would never have been called in the first place. Thierry
[toc] | [prev] | [next] | [standalone]
| From | Alexandre Belloni <alexandre.belloni@free-electrons.com> |
|---|---|
| Date | 2015-11-12 15:50 +0100 |
| Message-ID | <qu1mj-1Ij-35@gated-at.bofh.it> |
| In reply to | #1267693 |
Hi, On 12/11/2015 at 08:42:12 +0100, LABBE Corentin wrote : > of_match_device could return NULL, and so cause a NULL pointer > dereference later. > > Reported-by: coverity (CID 1324139) > Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com> > --- > drivers/pwm/pwm-sun4i.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/pwm/pwm-sun4i.c b/drivers/pwm/pwm-sun4i.c > index cd9dde5..3011fcc 100644 > --- a/drivers/pwm/pwm-sun4i.c > +++ b/drivers/pwm/pwm-sun4i.c > @@ -291,6 +291,8 @@ static int sun4i_pwm_probe(struct platform_device *pdev) > const struct of_device_id *match; > > match = of_match_device(sun4i_pwm_dt_ids, &pdev->dev); > + if (!match) > + return -ENODEV; > This will never happen. If it is not matching, then sun4i_pwm_probe is not called. -- Alexandre Belloni, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web