diff mbox

V4L: omap1-camera: fix Oops with NULL platform data

Message ID Pine.LNX.4.64.1109071548070.14818@axis700.grange (mailing list archive)
State New, archived
Headers show

Commit Message

Guennadi Liakhovetski Sept. 7, 2011, 1:49 p.m. UTC
Consistently check for platform data != NULL before dereferencing.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Cc: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
---
 drivers/media/video/omap1_camera.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

Comments

Janusz Krzysztofik Sept. 7, 2011, 5:55 p.m. UTC | #1
On Wed, 7 Sep 2011 at 15:49:15 Guennadi Liakhovetski wrote:
> Consistently check for platform data != NULL before dereferencing.

Sure, thanks for taking care of this.
Janusz

> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> Cc: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
> ---
>  drivers/media/video/omap1_camera.c |   10 +++++-----
>  1 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/media/video/omap1_camera.c
> b/drivers/media/video/omap1_camera.c index f24bcaf..e87ae2f 100644
> --- a/drivers/media/video/omap1_camera.c
> +++ b/drivers/media/video/omap1_camera.c
> @@ -1579,10 +1579,10 @@ static int __init omap1_cam_probe(struct
> platform_device *pdev) pcdev->clk = clk;
> 
>  	pcdev->pdata = pdev->dev.platform_data;
> -	pcdev->pflags = pcdev->pdata->flags;
> -
> -	if (pcdev->pdata)
> +	if (pcdev->pdata) {
> +		pcdev->pflags = pcdev->pdata->flags;
>  		pcdev->camexclk = pcdev->pdata->camexclk_khz * 1000;
> +	}
> 
>  	switch (pcdev->camexclk) {
>  	case 6000000:
> @@ -1592,6 +1592,7 @@ static int __init omap1_cam_probe(struct
> platform_device *pdev) case 24000000:
>  		break;
>  	default:
> +		/* pcdev->camexclk != 0 => pcdev->pdata != NULL */
>  		dev_warn(&pdev->dev,
>  				"Incorrect sensor clock frequency %ld kHz, "
>  				"should be one of 0, 6, 8, 9.6, 12 or 24 MHz, "
> @@ -1599,8 +1600,7 @@ static int __init omap1_cam_probe(struct
> platform_device *pdev) pcdev->pdata->camexclk_khz);
>  		pcdev->camexclk = 0;
>  	case 0:
> -		dev_info(&pdev->dev,
> -				"Not providing sensor clock\n");
> +		dev_info(&pdev->dev, "Not providing sensor clock\n");
>  	}
> 
>  	INIT_LIST_HEAD(&pcdev->capture);
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Guennadi Liakhovetski Sept. 7, 2011, 6:07 p.m. UTC | #2
On Wed, 7 Sep 2011, Janusz Krzysztofik wrote:

> On Wed, 7 Sep 2011 at 15:49:15 Guennadi Liakhovetski wrote:
> > Consistently check for platform data != NULL before dereferencing.
> 
> Sure, thanks for taking care of this.

I'll take it as an "Acked-by" ;-)

Thanks
Guennadi

> Janusz
> 
> > Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> > Cc: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
> > ---
> >  drivers/media/video/omap1_camera.c |   10 +++++-----
> >  1 files changed, 5 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/media/video/omap1_camera.c
> > b/drivers/media/video/omap1_camera.c index f24bcaf..e87ae2f 100644
> > --- a/drivers/media/video/omap1_camera.c
> > +++ b/drivers/media/video/omap1_camera.c
> > @@ -1579,10 +1579,10 @@ static int __init omap1_cam_probe(struct
> > platform_device *pdev) pcdev->clk = clk;
> > 
> >  	pcdev->pdata = pdev->dev.platform_data;
> > -	pcdev->pflags = pcdev->pdata->flags;
> > -
> > -	if (pcdev->pdata)
> > +	if (pcdev->pdata) {
> > +		pcdev->pflags = pcdev->pdata->flags;
> >  		pcdev->camexclk = pcdev->pdata->camexclk_khz * 1000;
> > +	}
> > 
> >  	switch (pcdev->camexclk) {
> >  	case 6000000:
> > @@ -1592,6 +1592,7 @@ static int __init omap1_cam_probe(struct
> > platform_device *pdev) case 24000000:
> >  		break;
> >  	default:
> > +		/* pcdev->camexclk != 0 => pcdev->pdata != NULL */
> >  		dev_warn(&pdev->dev,
> >  				"Incorrect sensor clock frequency %ld kHz, "
> >  				"should be one of 0, 6, 8, 9.6, 12 or 24 MHz, "
> > @@ -1599,8 +1600,7 @@ static int __init omap1_cam_probe(struct
> > platform_device *pdev) pcdev->pdata->camexclk_khz);
> >  		pcdev->camexclk = 0;
> >  	case 0:
> > -		dev_info(&pdev->dev,
> > -				"Not providing sensor clock\n");
> > +		dev_info(&pdev->dev, "Not providing sensor clock\n");
> >  	}
> > 
> >  	INIT_LIST_HEAD(&pcdev->capture);
> 

---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/media/video/omap1_camera.c b/drivers/media/video/omap1_camera.c
index f24bcaf..e87ae2f 100644
--- a/drivers/media/video/omap1_camera.c
+++ b/drivers/media/video/omap1_camera.c
@@ -1579,10 +1579,10 @@  static int __init omap1_cam_probe(struct platform_device *pdev)
 	pcdev->clk = clk;
 
 	pcdev->pdata = pdev->dev.platform_data;
-	pcdev->pflags = pcdev->pdata->flags;
-
-	if (pcdev->pdata)
+	if (pcdev->pdata) {
+		pcdev->pflags = pcdev->pdata->flags;
 		pcdev->camexclk = pcdev->pdata->camexclk_khz * 1000;
+	}
 
 	switch (pcdev->camexclk) {
 	case 6000000:
@@ -1592,6 +1592,7 @@  static int __init omap1_cam_probe(struct platform_device *pdev)
 	case 24000000:
 		break;
 	default:
+		/* pcdev->camexclk != 0 => pcdev->pdata != NULL */
 		dev_warn(&pdev->dev,
 				"Incorrect sensor clock frequency %ld kHz, "
 				"should be one of 0, 6, 8, 9.6, 12 or 24 MHz, "
@@ -1599,8 +1600,7 @@  static int __init omap1_cam_probe(struct platform_device *pdev)
 				pcdev->pdata->camexclk_khz);
 		pcdev->camexclk = 0;
 	case 0:
-		dev_info(&pdev->dev,
-				"Not providing sensor clock\n");
+		dev_info(&pdev->dev, "Not providing sensor clock\n");
 	}
 
 	INIT_LIST_HEAD(&pcdev->capture);