All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pwm: sun4i: fix a possible NULL dereference
@ 2015-11-12  7:42 ` LABBE Corentin
  0 siblings, 0 replies; 6+ messages in thread
From: LABBE Corentin @ 2015-11-12  7:42 UTC (permalink / raw)
  To: linux-arm-kernel, maxime.ripard, thierry.reding, wens
  Cc: LABBE Corentin, linux-kernel, linux-pwm

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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH] pwm: sun4i: fix a possible NULL dereference
@ 2015-11-12  7:42 ` LABBE Corentin
  0 siblings, 0 replies; 6+ messages in thread
From: LABBE Corentin @ 2015-11-12  7:42 UTC (permalink / raw)
  To: linux-arm-kernel

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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] pwm: sun4i: fix a possible NULL dereference
  2015-11-12  7:42 ` LABBE Corentin
@ 2015-11-12 12:38   ` Thierry Reding
  -1 siblings, 0 replies; 6+ messages in thread
From: Thierry Reding @ 2015-11-12 12:38 UTC (permalink / raw)
  To: LABBE Corentin
  Cc: linux-arm-kernel, maxime.ripard, wens, linux-kernel, linux-pwm

[-- Attachment #1: Type: text/plain, Size: 1062 bytes --]

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] pwm: sun4i: fix a possible NULL dereference
@ 2015-11-12 12:38   ` Thierry Reding
  0 siblings, 0 replies; 6+ messages in thread
From: Thierry Reding @ 2015-11-12 12:38 UTC (permalink / raw)
  To: linux-arm-kernel

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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20151112/044c5813/attachment.sig>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] pwm: sun4i: fix a possible NULL dereference
  2015-11-12  7:42 ` LABBE Corentin
@ 2015-11-12 14:47   ` Alexandre Belloni
  -1 siblings, 0 replies; 6+ messages in thread
From: Alexandre Belloni @ 2015-11-12 14:47 UTC (permalink / raw)
  To: LABBE Corentin
  Cc: linux-arm-kernel, maxime.ripard, thierry.reding, wens, linux-pwm,
	linux-kernel

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] pwm: sun4i: fix a possible NULL dereference
@ 2015-11-12 14:47   ` Alexandre Belloni
  0 siblings, 0 replies; 6+ messages in thread
From: Alexandre Belloni @ 2015-11-12 14:47 UTC (permalink / raw)
  To: linux-arm-kernel

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-11-12 14:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-12  7:42 [PATCH] pwm: sun4i: fix a possible NULL dereference LABBE Corentin
2015-11-12  7:42 ` LABBE Corentin
2015-11-12 12:38 ` Thierry Reding
2015-11-12 12:38   ` Thierry Reding
2015-11-12 14:47 ` Alexandre Belloni
2015-11-12 14:47   ` Alexandre Belloni

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.