Skip to contentSkip to conversation

iio: adc: at91_adc: Correct call to input_free_device

PATCH In review Himangi Saraogi 3 participants 4 messages Jun 13, 2014 – Jun 14, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: adc: at91_adc: Correct call to input_free_device

This error handling code can be reached before st->ts_input is initialized, so it is safer to always use the original name, input_dev.

A simplified version of the semantic match that finds this problem is:

// <smpl>
@r exists@
local idexpression struct input_dev * x;
expression ra,rr;
@@

* x = input_allocate_device(...)
... when != x = rr

     when != input_free_device(x,...)
     when != if (...) { ... input_free_device(x,...) ...}

if(...) { ... when != x = ra
when forall
* when != input_free_device(x,...)
\(return <+...x...+>; \| return...; \) }

// </smpl>

---
 drivers/iio/adc/at91_adc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/at91_adc.c +1 -1
index 3b5bacd..73b2bb5 100644
@@ -1114,7 +1114,7 @@ static int at91_ts_register(struct at91_adc_state *st,
 	return ret;
 
 err:
-	input_free_device(st->ts_input);
+	input_free_device(input);
 	return ret;
 }
 
Signature · 1 line
1.9.1
maintainer
#1 lore raw
Quoted 15 lines · Himangi Saraogi

This error handling code can be reached before st->ts_input is initialized, so it is safer to always use the original name, input_dev.

A simplified version of the semantic match that finds this problem is:

// <smpl>
@r exists@
local idexpression struct input_dev * x;
expression ra,rr;
@@

* x = input_allocate_device(...)
... when != x = rr

      when != input_free_device(x,...)
      when != if (...) { ... input_free_device(x,...) ...}
Quoted 8 lines

if(...) { ... when != x = ra
when forall
* when != input_free_device(x,...)
\(return <+...x...+>; \| return...; \) }

// </smpl>

The error handling in this function has been completely rewritten so the bug is no longer there and this no longer applies.

Thanks,

Jonathan

Quoted 18 lines
---
  drivers/iio/adc/at91_adc.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/at91_adc.c +1 -1
index 3b5bacd..73b2bb5 100644
@@ -1114,7 +1114,7 @@ static int at91_ts_register(struct at91_adc_state *st,
  	return ret;
 
  err:
-	input_free_device(st->ts_input);
+	input_free_device(input);
  	return ret;
  }
 
#2 lore raw
Quoted 21 lines · Jonathan Cameron
Quoted 20 lines · Himangi Saraogi

This error handling code can be reached before st->ts_input is initialized, so it is safer to always use the original name, input_dev.

A simplified version of the semantic match that finds this problem is:

// <smpl>
@r exists@
local idexpression struct input_dev * x;
expression ra,rr;
@@

* x = input_allocate_device(...)
... when != x = rr

     when != input_free_device(x,...)
     when != if (...) { ... input_free_device(x,...) ...}

if(...) { ... when != x = ra
when forall
* when != input_free_device(x,...)
\(return <+...x...+>; \| return...; \) }

Quoted 5 lines
Quoted 3 lines

// </smpl>

The error handling in this function has been completely rewritten so the bug is no longer there and this no longer applies.

Hum, actually, you are wrong and I introduced that bug in 3.16. The change didn't come from your tree so it is not up to date.

So either you take it after 3.16-rc1 or we can ask Nicolas to get it through the at91 tree.

Either way:

Signature · 3 lines
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
maintainer
#3 lore raw
Quoted 25 lines · Alexandre Belloni
Quoted 24 lines · Jonathan Cameron
Quoted 23 lines · Himangi Saraogi

This error handling code can be reached before st->ts_input is initialized, so it is safer to always use the original name, input_dev.

A simplified version of the semantic match that finds this problem is:

// <smpl>
@r exists@
local idexpression struct input_dev * x;
expression ra,rr;
@@

* x = input_allocate_device(...)
... when != x = rr

      when != input_free_device(x,...)
      when != if (...) { ... input_free_device(x,...) ...}

if(...) { ... when != x = ra
when forall
* when != input_free_device(x,...)
\(return <+...x...+>; \| return...; \) }

// </smpl>

Quoted 8 lines
Quoted 2 lines

The error handling in this function has been completely rewritten so the bug is no longer there and this no longer applies.

Hum, actually, you are wrong and I introduced that bug in 3.16. The change didn't come from your tree so it is not up to date.

So either you take it after 3.16-rc1 or we can ask Nicolas to get it through the at91 tree.

Ah, that would do it!
I'm lagging a bit (just sending a pull request for some fixes from pre 3.16 merge window opening). Will pick this up later in the week.

oops.

J

Quoted 6 lines

Either way: