linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: mcp320x: Fix NULL pointer dereference
@ 2015-07-10 20:55 Manfred Schlaegl
  2015-07-13 14:16 ` Michael Welling
  0 siblings, 1 reply; 5+ messages in thread
From: Manfred Schlaegl @ 2015-07-10 20:55 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald,
	Michael Welling, Manfred Schlaegl, linux-iio, linux-kernel,
	Manfred Schlaegl

On reading in_voltage_scale of we got an NULL pointer dereference Oops.

The reason for this is, that mcp320x_read_raw tries to access
chip_info->resolution from struct mcp320x, but chip_info is never set.

chip_info was never set since the driver was added, but there was no
acute problem, because it was not referenced.
The acute problem exists since
b12206e917ac34bec41b9ff93d37d8bd53a2b3bc
iio: adc: mcp320x. Add support for more ADCs

This patch fixes the issue by setting chip_info in mcp320x_probe.

Signed-off-by: Manfred Schlaegl <manfred.schlaegl@gmx.at>
---
 drivers/iio/adc/mcp320x.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/iio/adc/mcp320x.c b/drivers/iio/adc/mcp320x.c
index 8d9c9b9..d819823 100644
--- a/drivers/iio/adc/mcp320x.c
+++ b/drivers/iio/adc/mcp320x.c
@@ -299,6 +299,8 @@ static int mcp320x_probe(struct spi_device *spi)
 	indio_dev->channels = chip_info->channels;
 	indio_dev->num_channels = chip_info->num_channels;
 
+	adc->chip_info = chip_info;
+
 	adc->transfer[0].tx_buf = &adc->tx_buf;
 	adc->transfer[0].len = sizeof(adc->tx_buf);
 	adc->transfer[1].rx_buf = adc->rx_buf;
-- 
1.7.10.4


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

* Re: [PATCH] iio: mcp320x: Fix NULL pointer dereference
  2015-07-10 20:55 [PATCH] iio: mcp320x: Fix NULL pointer dereference Manfred Schlaegl
@ 2015-07-13 14:16 ` Michael Welling
  2015-07-14 11:53   ` Manfred Schlaegl
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Welling @ 2015-07-13 14:16 UTC (permalink / raw)
  To: Manfred Schlaegl
  Cc: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald, linux-iio, linux-kernel, Manfred Schlaegl

On Fri, Jul 10, 2015 at 10:55:30PM +0200, Manfred Schlaegl wrote:
> On reading in_voltage_scale of we got an NULL pointer dereference Oops.
> 
> The reason for this is, that mcp320x_read_raw tries to access
> chip_info->resolution from struct mcp320x, but chip_info is never set.
> 
> chip_info was never set since the driver was added, but there was no
> acute problem, because it was not referenced.
> The acute problem exists since
> b12206e917ac34bec41b9ff93d37d8bd53a2b3bc
> iio: adc: mcp320x. Add support for more ADCs
> 
> This patch fixes the issue by setting chip_info in mcp320x_probe.
> 
> Signed-off-by: Manfred Schlaegl <manfred.schlaegl@gmx.at>
> ---
>  drivers/iio/adc/mcp320x.c |    2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/iio/adc/mcp320x.c b/drivers/iio/adc/mcp320x.c
> index 8d9c9b9..d819823 100644
> --- a/drivers/iio/adc/mcp320x.c
> +++ b/drivers/iio/adc/mcp320x.c
> @@ -299,6 +299,8 @@ static int mcp320x_probe(struct spi_device *spi)
>  	indio_dev->channels = chip_info->channels;
>  	indio_dev->num_channels = chip_info->num_channels;
>  
> +	adc->chip_info = chip_info;
> +

Looks good to me.

Reviewed-by: Michael Welling <mwelling@ieee.org>

>  	adc->transfer[0].tx_buf = &adc->tx_buf;
>  	adc->transfer[0].len = sizeof(adc->tx_buf);
>  	adc->transfer[1].rx_buf = adc->rx_buf;
> -- 
> 1.7.10.4
> 

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

* Re: [PATCH] iio: mcp320x: Fix NULL pointer dereference
  2015-07-13 14:16 ` Michael Welling
@ 2015-07-14 11:53   ` Manfred Schlaegl
  2015-07-19 13:00     ` Jonathan Cameron
  0 siblings, 1 reply; 5+ messages in thread
From: Manfred Schlaegl @ 2015-07-14 11:53 UTC (permalink / raw)
  To: Michael Welling
  Cc: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald, linux-iio, linux-kernel, Manfred Schlaegl

On 2015-07-13 16:16, Michael Welling wrote:
> On Fri, Jul 10, 2015 at 10:55:30PM +0200, Manfred Schlaegl wrote:
>> On reading in_voltage_scale of we got an NULL pointer dereference Oops.
>>
>> The reason for this is, that mcp320x_read_raw tries to access
>> chip_info->resolution from struct mcp320x, but chip_info is never set.
>>
>> chip_info was never set since the driver was added, but there was no
>> acute problem, because it was not referenced.
>> The acute problem exists since
>> b12206e917ac34bec41b9ff93d37d8bd53a2b3bc
>> iio: adc: mcp320x. Add support for more ADCs
>>
>> This patch fixes the issue by setting chip_info in mcp320x_probe.
>>
>> Signed-off-by: Manfred Schlaegl <manfred.schlaegl@gmx.at>
>> ---
>>  drivers/iio/adc/mcp320x.c |    2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/iio/adc/mcp320x.c b/drivers/iio/adc/mcp320x.c
>> index 8d9c9b9..d819823 100644
>> --- a/drivers/iio/adc/mcp320x.c
>> +++ b/drivers/iio/adc/mcp320x.c
>> @@ -299,6 +299,8 @@ static int mcp320x_probe(struct spi_device *spi)
>>  	indio_dev->channels = chip_info->channels;
>>  	indio_dev->num_channels = chip_info->num_channels;
>>  
>> +	adc->chip_info = chip_info;
>> +
> 
> Looks good to me.
> 
> Reviewed-by: Michael Welling <mwelling@ieee.org>
> 
>>  	adc->transfer[0].tx_buf = &adc->tx_buf;
>>  	adc->transfer[0].len = sizeof(adc->tx_buf);
>>  	adc->transfer[1].rx_buf = adc->rx_buf;
>> -- 
>> 1.7.10.4
>>

Thanks for reviewing!

best regards,
manfred

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

* Re: [PATCH] iio: mcp320x: Fix NULL pointer dereference
  2015-07-14 11:53   ` Manfred Schlaegl
@ 2015-07-19 13:00     ` Jonathan Cameron
  2015-07-19 23:56       ` Michael Welling
  0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Cameron @ 2015-07-19 13:00 UTC (permalink / raw)
  To: Manfred Schlaegl, Michael Welling
  Cc: Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald, linux-iio,
	linux-kernel, Manfred Schlaegl

On 14/07/15 12:53, Manfred Schlaegl wrote:
> On 2015-07-13 16:16, Michael Welling wrote:
>> On Fri, Jul 10, 2015 at 10:55:30PM +0200, Manfred Schlaegl wrote:
>>> On reading in_voltage_scale of we got an NULL pointer dereference Oops.
>>>
>>> The reason for this is, that mcp320x_read_raw tries to access
>>> chip_info->resolution from struct mcp320x, but chip_info is never set.
>>>
>>> chip_info was never set since the driver was added, but there was no
>>> acute problem, because it was not referenced.
>>> The acute problem exists since
>>> b12206e917ac34bec41b9ff93d37d8bd53a2b3bc
>>> iio: adc: mcp320x. Add support for more ADCs
>>>
>>> This patch fixes the issue by setting chip_info in mcp320x_probe.
>>>
>>> Signed-off-by: Manfred Schlaegl <manfred.schlaegl@gmx.at>
>>> ---
>>>  drivers/iio/adc/mcp320x.c |    2 ++
>>>  1 file changed, 2 insertions(+)
>>>
>>> diff --git a/drivers/iio/adc/mcp320x.c b/drivers/iio/adc/mcp320x.c
>>> index 8d9c9b9..d819823 100644
>>> --- a/drivers/iio/adc/mcp320x.c
>>> +++ b/drivers/iio/adc/mcp320x.c
>>> @@ -299,6 +299,8 @@ static int mcp320x_probe(struct spi_device *spi)
>>>  	indio_dev->channels = chip_info->channels;
>>>  	indio_dev->num_channels = chip_info->num_channels;
>>>  
>>> +	adc->chip_info = chip_info;
>>> +
>>
>> Looks good to me.
>>
>> Reviewed-by: Michael Welling <mwelling@ieee.org>
>>
>>>  	adc->transfer[0].tx_buf = &adc->tx_buf;
>>>  	adc->transfer[0].len = sizeof(adc->tx_buf);
>>>  	adc->transfer[1].rx_buf = adc->rx_buf;
>>> -- 
>>> 1.7.10.4
>>>
> 
> Thanks for reviewing!
> 
> best regards,
> manfred
> 
Applied to the fixes-togreg branch of iio.git

Michael, there are moves afoot to clarify the meaning of reviewed-by
as covering only more substantial reviews (kind of tricky on a one liner
like this!)  Hence for similar patches in future, an Acked-by may
be more appropriate.

Thanks,

Jonathan

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

* Re: [PATCH] iio: mcp320x: Fix NULL pointer dereference
  2015-07-19 13:00     ` Jonathan Cameron
@ 2015-07-19 23:56       ` Michael Welling
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Welling @ 2015-07-19 23:56 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Manfred Schlaegl, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald, linux-iio, linux-kernel, Manfred Schlaegl

On Sun, Jul 19, 2015 at 02:00:24PM +0100, Jonathan Cameron wrote:
> Applied to the fixes-togreg branch of iio.git
> 
> Michael, there are moves afoot to clarify the meaning of reviewed-by
> as covering only more substantial reviews (kind of tricky on a one liner
> like this!)  Hence for similar patches in future, an Acked-by may
> be more appropriate.
>

Actually I did review the patch and sent comments to the author.

In my haste I pressed reply istead of reply-all.. Oooops.

> Thanks,
> 
> Jonathan

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

end of thread, other threads:[~2015-07-19 23:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-10 20:55 [PATCH] iio: mcp320x: Fix NULL pointer dereference Manfred Schlaegl
2015-07-13 14:16 ` Michael Welling
2015-07-14 11:53   ` Manfred Schlaegl
2015-07-19 13:00     ` Jonathan Cameron
2015-07-19 23:56       ` Michael Welling

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