devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] i2c-s3c2410: Fix potential NULL pointer dereference
@ 2012-09-18  8:48 Sachin Kamat
       [not found] ` <1347958128-13146-1-git-send-email-sachin.kamat-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Sachin Kamat @ 2012-09-18  8:48 UTC (permalink / raw)
  To: linux-i2c-u79uwXL29TY76Z2rM5mHXA
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	sachin.kamat-QSEj5FYQhm4dnm+yROfE0A,
	patches-QSEj5FYQhm4dnm+yROfE0A, Wolfram Sang, Grant Likely,
	Rob Herring

of_match_node() returns NULL if a device_node does not have
a matching of_match structure. Thus the return value needs to be
checked for NULL to avoid NULL pointer dereferencing.

Cc: Wolfram Sang <w.sang-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
Cc: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
Cc: Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>
Signed-off-by: Sachin Kamat <sachin.kamat-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
---
 drivers/i2c/busses/i2c-s3c2410.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 5ae3b02..d906523 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -123,6 +123,8 @@ static inline unsigned int s3c24xx_get_device_quirks(struct platform_device *pde
 	if (pdev->dev.of_node) {
 		const struct of_device_id *match;
 		match = of_match_node(s3c24xx_i2c_match, pdev->dev.of_node);
+		if (!match)
+			return 0;
 		return (unsigned int)match->data;
 	}
 
-- 
1.7.4.1

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

* Re: [PATCH] i2c-s3c2410: Fix potential NULL pointer dereference
       [not found] ` <1347958128-13146-1-git-send-email-sachin.kamat-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
@ 2012-09-24  3:54   ` Sachin Kamat
  2012-09-26  4:07   ` Sachin Kamat
  2012-10-06 13:37   ` Wolfram Sang
  2 siblings, 0 replies; 4+ messages in thread
From: Sachin Kamat @ 2012-09-24  3:54 UTC (permalink / raw)
  To: linux-i2c-u79uwXL29TY76Z2rM5mHXA
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	sachin.kamat-QSEj5FYQhm4dnm+yROfE0A,
	patches-QSEj5FYQhm4dnm+yROfE0A, Wolfram Sang, Grant Likely,
	Rob Herring

ping..

On 18 September 2012 14:18, Sachin Kamat <sachin.kamat-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> wrote:
> of_match_node() returns NULL if a device_node does not have
> a matching of_match structure. Thus the return value needs to be
> checked for NULL to avoid NULL pointer dereferencing.
>
> Cc: Wolfram Sang <w.sang-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> Cc: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
> Cc: Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>
> Signed-off-by: Sachin Kamat <sachin.kamat-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> ---
>  drivers/i2c/busses/i2c-s3c2410.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
> index 5ae3b02..d906523 100644
> --- a/drivers/i2c/busses/i2c-s3c2410.c
> +++ b/drivers/i2c/busses/i2c-s3c2410.c
> @@ -123,6 +123,8 @@ static inline unsigned int s3c24xx_get_device_quirks(struct platform_device *pde
>         if (pdev->dev.of_node) {
>                 const struct of_device_id *match;
>                 match = of_match_node(s3c24xx_i2c_match, pdev->dev.of_node);
> +               if (!match)
> +                       return 0;
>                 return (unsigned int)match->data;
>         }
>
> --
> 1.7.4.1
>



-- 
With warm regards,
Sachin

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

* Re: [PATCH] i2c-s3c2410: Fix potential NULL pointer dereference
       [not found] ` <1347958128-13146-1-git-send-email-sachin.kamat-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
  2012-09-24  3:54   ` Sachin Kamat
@ 2012-09-26  4:07   ` Sachin Kamat
  2012-10-06 13:37   ` Wolfram Sang
  2 siblings, 0 replies; 4+ messages in thread
From: Sachin Kamat @ 2012-09-26  4:07 UTC (permalink / raw)
  To: linux-i2c-u79uwXL29TY76Z2rM5mHXA
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	sachin.kamat-QSEj5FYQhm4dnm+yROfE0A,
	patches-QSEj5FYQhm4dnm+yROfE0A, Wolfram Sang, Grant Likely,
	Rob Herring

Hi,

Can we have this fix for the 3.6 series please?

On 18 September 2012 14:18, Sachin Kamat <sachin.kamat-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> wrote:
> of_match_node() returns NULL if a device_node does not have
> a matching of_match structure. Thus the return value needs to be
> checked for NULL to avoid NULL pointer dereferencing.
>
> Cc: Wolfram Sang <w.sang-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> Cc: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
> Cc: Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>
> Signed-off-by: Sachin Kamat <sachin.kamat-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> ---
>  drivers/i2c/busses/i2c-s3c2410.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
> index 5ae3b02..d906523 100644
> --- a/drivers/i2c/busses/i2c-s3c2410.c
> +++ b/drivers/i2c/busses/i2c-s3c2410.c
> @@ -123,6 +123,8 @@ static inline unsigned int s3c24xx_get_device_quirks(struct platform_device *pde
>         if (pdev->dev.of_node) {
>                 const struct of_device_id *match;
>                 match = of_match_node(s3c24xx_i2c_match, pdev->dev.of_node);
> +               if (!match)
> +                       return 0;
>                 return (unsigned int)match->data;
>         }
>
> --
> 1.7.4.1
>



-- 
With warm regards,
Sachin

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

* Re: [PATCH] i2c-s3c2410: Fix potential NULL pointer dereference
       [not found] ` <1347958128-13146-1-git-send-email-sachin.kamat-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
  2012-09-24  3:54   ` Sachin Kamat
  2012-09-26  4:07   ` Sachin Kamat
@ 2012-10-06 13:37   ` Wolfram Sang
  2 siblings, 0 replies; 4+ messages in thread
From: Wolfram Sang @ 2012-10-06 13:37 UTC (permalink / raw)
  To: Sachin Kamat
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	patches-QSEj5FYQhm4dnm+yROfE0A, Grant Likely, Rob Herring

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

On Tue, Sep 18, 2012 at 02:18:48PM +0530, Sachin Kamat wrote:
> of_match_node() returns NULL if a device_node does not have
> a matching of_match structure. Thus the return value needs to be
> checked for NULL to avoid NULL pointer dereferencing.

I am missing how the driver can be matched to the device if there is no
fitting device node?

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

end of thread, other threads:[~2012-10-06 13:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-18  8:48 [PATCH] i2c-s3c2410: Fix potential NULL pointer dereference Sachin Kamat
     [not found] ` <1347958128-13146-1-git-send-email-sachin.kamat-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2012-09-24  3:54   ` Sachin Kamat
2012-09-26  4:07   ` Sachin Kamat
2012-10-06 13:37   ` Wolfram Sang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).