All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iio: adc: at91: unbreak channel adc channel 3
@ 2016-08-08 12:42 Anders Darander
  2016-08-08 13:52 ` Alexandre Belloni
  0 siblings, 1 reply; 3+ messages in thread
From: Anders Darander @ 2016-08-08 12:42 UTC (permalink / raw)
  To: linux-iio, jic23, alexandre.belloni
  Cc: knaack.h, lars, pmeerw, linux-kernel, Anders Darander

The driver always assumes that an input device has been created when
reading channel 3. This causes a kernel panic when dereferencing
st->ts_input.

The change was introduced in
commit 84882b060301 ("iio: adc: at91_adc: Add support for touchscreens
without TSMR"). Earlier versions only entered that part of the if-else
statement if only the following flags are set:

AT91_ADC_IER_XRDY | AT91_ADC_IER_YRDY | AT91_ADC_IER_PRDY

Signed-off-by: Anders Darander <anders@chargestorm.se>
---
 drivers/iio/adc/at91_adc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
index 52430ba..0438c68 100644
--- a/drivers/iio/adc/at91_adc.c
+++ b/drivers/iio/adc/at91_adc.c
@@ -381,8 +381,8 @@ static irqreturn_t at91_adc_rl_interrupt(int irq, void *private)
 		st->ts_bufferedmeasure = false;
 		input_report_key(st->ts_input, BTN_TOUCH, 0);
 		input_sync(st->ts_input);
-	} else if (status & AT91_ADC_EOC(3)) {
-		/* Conversion finished */
+	} else if (status & AT91_ADC_EOC(3) && st->ts_input) {
+		/* Conversion finished and we've a touchscreen */
 		if (st->ts_bufferedmeasure) {
 			/*
 			 * Last measurement is always discarded, since it can
-- 
2.8.1

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

* Re: [PATCH] iio: adc: at91: unbreak channel adc channel 3
  2016-08-08 12:42 [PATCH] iio: adc: at91: unbreak channel adc channel 3 Anders Darander
@ 2016-08-08 13:52 ` Alexandre Belloni
  2016-08-15 16:15   ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: Alexandre Belloni @ 2016-08-08 13:52 UTC (permalink / raw)
  To: Anders Darander; +Cc: linux-iio, jic23, knaack.h, lars, pmeerw, linux-kernel

On 08/08/2016 at 14:42:16 +0200, Anders Darander wrote :
> The driver always assumes that an input device has been created when
> reading channel 3. This causes a kernel panic when dereferencing
> st->ts_input.
> 
> The change was introduced in
> commit 84882b060301 ("iio: adc: at91_adc: Add support for touchscreens
> without TSMR"). Earlier versions only entered that part of the if-else
> statement if only the following flags are set:
> 
> AT91_ADC_IER_XRDY | AT91_ADC_IER_YRDY | AT91_ADC_IER_PRDY
> 
> Signed-off-by: Anders Darander <anders@chargestorm.se>
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>

> ---
>  drivers/iio/adc/at91_adc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
> index 52430ba..0438c68 100644
> --- a/drivers/iio/adc/at91_adc.c
> +++ b/drivers/iio/adc/at91_adc.c
> @@ -381,8 +381,8 @@ static irqreturn_t at91_adc_rl_interrupt(int irq, void *private)
>  		st->ts_bufferedmeasure = false;
>  		input_report_key(st->ts_input, BTN_TOUCH, 0);
>  		input_sync(st->ts_input);
> -	} else if (status & AT91_ADC_EOC(3)) {
> -		/* Conversion finished */
> +	} else if (status & AT91_ADC_EOC(3) && st->ts_input) {
> +		/* Conversion finished and we've a touchscreen */
>  		if (st->ts_bufferedmeasure) {
>  			/*
>  			 * Last measurement is always discarded, since it can
> -- 
> 2.8.1
> 

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

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

* Re: [PATCH] iio: adc: at91: unbreak channel adc channel 3
  2016-08-08 13:52 ` Alexandre Belloni
@ 2016-08-15 16:15   ` Jonathan Cameron
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2016-08-15 16:15 UTC (permalink / raw)
  To: Alexandre Belloni, Anders Darander
  Cc: linux-iio, knaack.h, lars, pmeerw, linux-kernel

On 08/08/16 14:52, Alexandre Belloni wrote:
> On 08/08/2016 at 14:42:16 +0200, Anders Darander wrote :
>> The driver always assumes that an input device has been created when
>> reading channel 3. This causes a kernel panic when dereferencing
>> st->ts_input.
>>
>> The change was introduced in
>> commit 84882b060301 ("iio: adc: at91_adc: Add support for touchscreens
>> without TSMR"). Earlier versions only entered that part of the if-else
>> statement if only the following flags are set:
>>
>> AT91_ADC_IER_XRDY | AT91_ADC_IER_YRDY | AT91_ADC_IER_PRDY
>>
>> Signed-off-by: Anders Darander <anders@chargestorm.se>
> Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Applied and marked for stable.

Thanks in particular for the thorough description!

Jonathan
> 
>> ---
>>  drivers/iio/adc/at91_adc.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
>> index 52430ba..0438c68 100644
>> --- a/drivers/iio/adc/at91_adc.c
>> +++ b/drivers/iio/adc/at91_adc.c
>> @@ -381,8 +381,8 @@ static irqreturn_t at91_adc_rl_interrupt(int irq, void *private)
>>  		st->ts_bufferedmeasure = false;
>>  		input_report_key(st->ts_input, BTN_TOUCH, 0);
>>  		input_sync(st->ts_input);
>> -	} else if (status & AT91_ADC_EOC(3)) {
>> -		/* Conversion finished */
>> +	} else if (status & AT91_ADC_EOC(3) && st->ts_input) {
>> +		/* Conversion finished and we've a touchscreen */
>>  		if (st->ts_bufferedmeasure) {
>>  			/*
>>  			 * Last measurement is always discarded, since it can
>> -- 
>> 2.8.1
>>
> 

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

end of thread, other threads:[~2016-08-15 16:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-08 12:42 [PATCH] iio: adc: at91: unbreak channel adc channel 3 Anders Darander
2016-08-08 13:52 ` Alexandre Belloni
2016-08-15 16:15   ` Jonathan Cameron

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.