linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch 1/2] input/tps6507x-ts: dereferencing before checking
@ 2010-05-31 12:01 Dan Carpenter
  2010-05-31 19:17 ` Dmitry Torokhov
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2010-05-31 12:01 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Todd Fischer, Samuel Ortiz, linux-input, kernel-janitors

This patch moves the dereference after the check for NULL.

Signed-off-by: Dan Carpenter <error27@gmail.com>

diff --git a/drivers/input/touchscreen/tps6507x-ts.c b/drivers/input/touchscreen/tps6507x-ts.c
index 5de80a1..b99db09 100644
--- a/drivers/input/touchscreen/tps6507x-ts.c
+++ b/drivers/input/touchscreen/tps6507x-ts.c
@@ -355,10 +355,11 @@ static int __devexit tps6507x_ts_remove(struct platform_device *pdev)
 {
 	struct tps6507x_dev *tps6507x_dev = platform_get_drvdata(pdev);
 	struct tps6507x_ts *tsc = tps6507x_dev->ts;
-	struct input_dev *input_dev = tsc->input_dev;
+	struct input_dev *input_dev;
 
 	if (!tsc)
 		return 0;
+	input_dev = tsc->input_dev;
 
 	cancel_delayed_work(&tsc->work);
 	flush_workqueue(tsc->wq);

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

* Re: [patch 1/2] input/tps6507x-ts: dereferencing before checking
  2010-05-31 12:01 [patch 1/2] input/tps6507x-ts: dereferencing before checking Dan Carpenter
@ 2010-05-31 19:17 ` Dmitry Torokhov
  2010-05-31 20:40   ` Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Torokhov @ 2010-05-31 19:17 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Todd Fischer, Samuel Ortiz, linux-input, kernel-janitors

On Mon, May 31, 2010 at 02:01:22PM +0200, Dan Carpenter wrote:
> This patch moves the dereference after the check for NULL.
> 
> Signed-off-by: Dan Carpenter <error27@gmail.com>
> 
> diff --git a/drivers/input/touchscreen/tps6507x-ts.c b/drivers/input/touchscreen/tps6507x-ts.c
> index 5de80a1..b99db09 100644
> --- a/drivers/input/touchscreen/tps6507x-ts.c
> +++ b/drivers/input/touchscreen/tps6507x-ts.c
> @@ -355,10 +355,11 @@ static int __devexit tps6507x_ts_remove(struct platform_device *pdev)
>  {
>  	struct tps6507x_dev *tps6507x_dev = platform_get_drvdata(pdev);
>  	struct tps6507x_ts *tsc = tps6507x_dev->ts;
> -	struct input_dev *input_dev = tsc->input_dev;
> +	struct input_dev *input_dev;
>  
>  	if (!tsc)
>  		return 0;
> +	input_dev = tsc->input_dev;
>  

Why would tsc ever be NULL?

Also I really do not like that pdev's driver data that is supposed to be
driver-private data is being used by the parent. Parent should be using
it's own drvdata and leave child's data alone. We should probably do in
platform code what I2C is about to do and clear drvdata on unbind
automatically to prevent this kind of misuse.

-- 
Dmitry

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

* Re: [patch 1/2] input/tps6507x-ts: dereferencing before checking
  2010-05-31 19:17 ` Dmitry Torokhov
@ 2010-05-31 20:40   ` Dan Carpenter
  0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2010-05-31 20:40 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Todd Fischer, Samuel Ortiz, linux-input, kernel-janitors

On Mon, May 31, 2010 at 12:17:23PM -0700, Dmitry Torokhov wrote:
> > --- a/drivers/input/touchscreen/tps6507x-ts.c
> > +++ b/drivers/input/touchscreen/tps6507x-ts.c
> > @@ -355,10 +355,11 @@ static int __devexit tps6507x_ts_remove(struct platform_device *pdev)
> >  {
> >  	struct tps6507x_dev *tps6507x_dev = platform_get_drvdata(pdev);
> >  	struct tps6507x_ts *tsc = tps6507x_dev->ts;
> > -	struct input_dev *input_dev = tsc->input_dev;
> > +	struct input_dev *input_dev;
> >  
> >  	if (!tsc)
> >  		return 0;
> > +	input_dev = tsc->input_dev;
> >  
> 
> Why would tsc ever be NULL?
> 
> Also I really do not like that pdev's driver data that is supposed to be
> driver-private data is being used by the parent. Parent should be using
> it's own drvdata and leave child's data alone. We should probably do in
> platform code what I2C is about to do and clear drvdata on unbind
> automatically to prevent this kind of misuse.
> 

Uh...  Sorry I was just messing with my static checker and didn't look
into it deeply enough.

All your points are valid ones of course.  This is fairly new driver so
we might be able to ask the maintainer.  :)  Todd, do you want to help
us out?

regards,
dan carpenter


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

end of thread, other threads:[~2010-05-31 20:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-31 12:01 [patch 1/2] input/tps6507x-ts: dereferencing before checking Dan Carpenter
2010-05-31 19:17 ` Dmitry Torokhov
2010-05-31 20:40   ` Dan Carpenter

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).