Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1652114 > unrolled thread

[PATCH] iio: adc: meson-saradc: use NULL instead of 0 for pointer

Started byPaolo Cretaro <paolocretaro@gmail.com>
First post2017-05-28 13:30 +0200
Last post2017-06-06 11:30 +0200
Articles 7 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] iio: adc: meson-saradc: use NULL instead of 0 for pointer Paolo Cretaro <paolocretaro@gmail.com> - 2017-05-28 13:30 +0200
    Re: [PATCH] iio: adc: meson-saradc: use NULL instead of 0 for  pointer Jonathan Cameron <jic23@kernel.org> - 2017-05-28 16:50 +0200
      Re: [PATCH] iio: adc: meson-saradc: use NULL instead of 0 for pointer Paolo Cretaro <paolocretaro@gmail.com> - 2017-05-28 20:00 +0200
      Re: [PATCH] iio: adc: meson-saradc: use NULL instead of 0 for pointer Martin Blumenstingl <martin.blumenstingl@googlemail.com> - 2017-05-28 23:20 +0200
        Re: [PATCH] iio: adc: meson-saradc: use NULL instead of 0 for  pointer Jonathan Cameron <jic23@kernel.org> - 2017-06-03 11:00 +0200
          Re: [PATCH] iio: adc: meson-saradc: use NULL instead of 0 for pointer Martin Blumenstingl <martin.blumenstingl@googlemail.com> - 2017-06-04 15:40 +0200
            Re: [PATCH] iio: adc: meson-saradc: use NULL instead of 0 for pointer Paolo Cretaro <paolocretaro@gmail.com> - 2017-06-06 11:30 +0200

#1652114 — [PATCH] iio: adc: meson-saradc: use NULL instead of 0 for pointer

FromPaolo Cretaro <paolocretaro@gmail.com>
Date2017-05-28 13:30 +0200
Subject[PATCH] iio: adc: meson-saradc: use NULL instead of 0 for pointer
Message-ID<tM4yt-1j1-9@gated-at.bofh.it>
Fix sparse warning: Using plain integer as NULL pointer

Signed-off-by: Paolo Cretaro <paolocretaro@gmail.com>
---
 drivers/iio/adc/meson_saradc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c
index 81cd39a57fe3..fb3f67a9ae1f 100644
--- a/drivers/iio/adc/meson_saradc.c
+++ b/drivers/iio/adc/meson_saradc.c
@@ -481,7 +481,7 @@ static void meson_sar_adc_clear_fifo(struct iio_dev *indio_dev)
 		if (!meson_sar_adc_get_fifo_count(indio_dev))
 			break;
 
-		regmap_read(priv->regmap, MESON_SAR_ADC_FIFO_RD, 0);
+		regmap_read(priv->regmap, MESON_SAR_ADC_FIFO_RD, NULL);
 	}
 }
 
-- 
2.13.0

[toc] | [next] | [standalone]


#1652146 — Re: [PATCH] iio: adc: meson-saradc: use NULL instead of 0 for pointer

FromJonathan Cameron <jic23@kernel.org>
Date2017-05-28 16:50 +0200
SubjectRe: [PATCH] iio: adc: meson-saradc: use NULL instead of 0 for pointer
Message-ID<tM7G2-3f9-25@gated-at.bofh.it>
In reply to#1652114
On Sun, 28 May 2017 13:24:38 +0200
Paolo Cretaro <paolocretaro@gmail.com> wrote:

> Fix sparse warning: Using plain integer as NULL pointer
> 
> Signed-off-by: Paolo Cretaro <paolocretaro@gmail.com>
This looks fine to me, but ideally you should always try to include
the driver author - particularly in the case of patches to a recent
driver such as this one.

To that end I've cc'd Martin.

Jonathan
> ---
>  drivers/iio/adc/meson_saradc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c
> index 81cd39a57fe3..fb3f67a9ae1f 100644
> --- a/drivers/iio/adc/meson_saradc.c
> +++ b/drivers/iio/adc/meson_saradc.c
> @@ -481,7 +481,7 @@ static void meson_sar_adc_clear_fifo(struct iio_dev *indio_dev)
>  		if (!meson_sar_adc_get_fifo_count(indio_dev))
>  			break;
>  
> -		regmap_read(priv->regmap, MESON_SAR_ADC_FIFO_RD, 0);
> +		regmap_read(priv->regmap, MESON_SAR_ADC_FIFO_RD, NULL);
>  	}
>  }
>  

[toc] | [prev] | [next] | [standalone]


#1652186

FromPaolo Cretaro <paolocretaro@gmail.com>
Date2017-05-28 20:00 +0200
Message-ID<tMaDT-56H-1@gated-at.bofh.it>
In reply to#1652146
On 28/05/2017 16:43, Jonathan Cameron wrote:
> On Sun, 28 May 2017 13:24:38 +0200
> Paolo Cretaro <paolocretaro@gmail.com> wrote:
> 
>> Fix sparse warning: Using plain integer as NULL pointer
>>
>> Signed-off-by: Paolo Cretaro <paolocretaro@gmail.com>
> This looks fine to me, but ideally you should always try to include
> the driver author - particularly in the case of patches to a recent
> driver such as this one.
Sure, thanks for pointing this out, I just felt a bit embarrassed to bother
too many people with such a trivial patch.

Paolo
> 
> To that end I've cc'd Martin.
> 
> Jonathan
>> ---
>>  drivers/iio/adc/meson_saradc.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c
>> index 81cd39a57fe3..fb3f67a9ae1f 100644
>> --- a/drivers/iio/adc/meson_saradc.c
>> +++ b/drivers/iio/adc/meson_saradc.c
>> @@ -481,7 +481,7 @@ static void meson_sar_adc_clear_fifo(struct iio_dev *indio_dev)
>>  		if (!meson_sar_adc_get_fifo_count(indio_dev))
>>  			break;
>>  
>> -		regmap_read(priv->regmap, MESON_SAR_ADC_FIFO_RD, 0);
>> +		regmap_read(priv->regmap, MESON_SAR_ADC_FIFO_RD, NULL);
>>  	}
>>  }
>>  
> 

[toc] | [prev] | [next] | [standalone]


#1652206

FromMartin Blumenstingl <martin.blumenstingl@googlemail.com>
Date2017-05-28 23:20 +0200
Message-ID<tMdLs-7hB-7@gated-at.bofh.it>
In reply to#1652146
Hi Paolo, Hi Jonathan,

On Sun, May 28, 2017 at 4:43 PM, Jonathan Cameron <jic23@kernel.org> wrote:
> On Sun, 28 May 2017 13:24:38 +0200
> Paolo Cretaro <paolocretaro@gmail.com> wrote:
>
>> Fix sparse warning: Using plain integer as NULL pointer
>>
>> Signed-off-by: Paolo Cretaro <paolocretaro@gmail.com>
> This looks fine to me, but ideally you should always try to include
> the driver author - particularly in the case of patches to a recent
> driver such as this one.
>
> To that end I've cc'd Martin.
thanks for spotting this (and providing a patch to fix it)
this looks good to me, so:
Acked-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>

if you can wait until next weekend then I can also test this on real hardware.

> Jonathan
>> ---
>>  drivers/iio/adc/meson_saradc.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c
>> index 81cd39a57fe3..fb3f67a9ae1f 100644
>> --- a/drivers/iio/adc/meson_saradc.c
>> +++ b/drivers/iio/adc/meson_saradc.c
>> @@ -481,7 +481,7 @@ static void meson_sar_adc_clear_fifo(struct iio_dev *indio_dev)
>>               if (!meson_sar_adc_get_fifo_count(indio_dev))
>>                       break;
>>
>> -             regmap_read(priv->regmap, MESON_SAR_ADC_FIFO_RD, 0);
>> +             regmap_read(priv->regmap, MESON_SAR_ADC_FIFO_RD, NULL);
>>       }
>>  }
>>
>

Regards,
Martin

[toc] | [prev] | [next] | [standalone]


#1656760 — Re: [PATCH] iio: adc: meson-saradc: use NULL instead of 0 for pointer

FromJonathan Cameron <jic23@kernel.org>
Date2017-06-03 11:00 +0200
SubjectRe: [PATCH] iio: adc: meson-saradc: use NULL instead of 0 for pointer
Message-ID<tOd4B-4OP-7@gated-at.bofh.it>
In reply to#1652206
On Sun, 28 May 2017 23:17:57 +0200
Martin Blumenstingl <martin.blumenstingl@googlemail.com> wrote:

> Hi Paolo, Hi Jonathan,
> 
> On Sun, May 28, 2017 at 4:43 PM, Jonathan Cameron <jic23@kernel.org> wrote:
> > On Sun, 28 May 2017 13:24:38 +0200
> > Paolo Cretaro <paolocretaro@gmail.com> wrote:
> >  
> >> Fix sparse warning: Using plain integer as NULL pointer
> >>
> >> Signed-off-by: Paolo Cretaro <paolocretaro@gmail.com>  
> > This looks fine to me, but ideally you should always try to include
> > the driver author - particularly in the case of patches to a recent
> > driver such as this one.
> >
> > To that end I've cc'd Martin.  
> thanks for spotting this (and providing a patch to fix it)
> this looks good to me, so:
> Acked-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
> 
> if you can wait until next weekend then I can also test this on real hardware.
I've applied it to the togreg branch of iio.git but as that always goes out
as testing for at least a few days first (which I will happily rebase) give
me a shout if anything goes wrong!

Jonathan
> 
> > Jonathan  
> >> ---
> >>  drivers/iio/adc/meson_saradc.c | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c
> >> index 81cd39a57fe3..fb3f67a9ae1f 100644
> >> --- a/drivers/iio/adc/meson_saradc.c
> >> +++ b/drivers/iio/adc/meson_saradc.c
> >> @@ -481,7 +481,7 @@ static void meson_sar_adc_clear_fifo(struct iio_dev *indio_dev)
> >>               if (!meson_sar_adc_get_fifo_count(indio_dev))
> >>                       break;
> >>
> >> -             regmap_read(priv->regmap, MESON_SAR_ADC_FIFO_RD, 0);
> >> +             regmap_read(priv->regmap, MESON_SAR_ADC_FIFO_RD, NULL);
> >>       }
> >>  }
> >>  
> >  
> 
> Regards,
> Martin

[toc] | [prev] | [next] | [standalone]


#1657072

FromMartin Blumenstingl <martin.blumenstingl@googlemail.com>
Date2017-06-04 15:40 +0200
Message-ID<tODV7-5Ir-9@gated-at.bofh.it>
In reply to#1656760
Hi Paolo, Hi Jonathan,

On Sat, Jun 3, 2017 at 10:52 AM, Jonathan Cameron <jic23@kernel.org> wrote:
> On Sun, 28 May 2017 23:17:57 +0200
> Martin Blumenstingl <martin.blumenstingl@googlemail.com> wrote:
>
>> Hi Paolo, Hi Jonathan,
>>
>> On Sun, May 28, 2017 at 4:43 PM, Jonathan Cameron <jic23@kernel.org> wrote:
>> > On Sun, 28 May 2017 13:24:38 +0200
>> > Paolo Cretaro <paolocretaro@gmail.com> wrote:
>> >
>> >> Fix sparse warning: Using plain integer as NULL pointer
>> >>
>> >> Signed-off-by: Paolo Cretaro <paolocretaro@gmail.com>
>> > This looks fine to me, but ideally you should always try to include
>> > the driver author - particularly in the case of patches to a recent
>> > driver such as this one.
>> >
>> > To that end I've cc'd Martin.
>> thanks for spotting this (and providing a patch to fix it)
>> this looks good to me, so:
>> Acked-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
>>
>> if you can wait until next weekend then I can also test this on real hardware.
> I've applied it to the togreg branch of iio.git but as that always goes out
> as testing for at least a few days first (which I will happily rebase) give
> me a shout if anything goes wrong!
I have tested this on actual hardware and it seems that there's a bug
in the meson-saradc driver (before and after this patch):
if there are still "old" values in the FIFO then the driver currently
crashes because regmap_read (regmap_mmio_read in case of the
meson-saradc driver to be precise) de-references the "value" pointer
(the parameter which we're trying to clean up here) -> this leads to a
NULL de-reference. this happens regardless of whether we are passing
"0" or "NULL"

I posted a patch which fixes the crash - and as a bonus this should
also fix the sparse warning reported by Paolo:
http://lists.infradead.org/pipermail/linux-amlogic/2017-June/003863.html

> Jonathan
>>
>> > Jonathan
>> >> ---
>> >>  drivers/iio/adc/meson_saradc.c | 2 +-
>> >>  1 file changed, 1 insertion(+), 1 deletion(-)
>> >>
>> >> diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c
>> >> index 81cd39a57fe3..fb3f67a9ae1f 100644
>> >> --- a/drivers/iio/adc/meson_saradc.c
>> >> +++ b/drivers/iio/adc/meson_saradc.c
>> >> @@ -481,7 +481,7 @@ static void meson_sar_adc_clear_fifo(struct iio_dev *indio_dev)
>> >>               if (!meson_sar_adc_get_fifo_count(indio_dev))
>> >>                       break;
>> >>
>> >> -             regmap_read(priv->regmap, MESON_SAR_ADC_FIFO_RD, 0);
>> >> +             regmap_read(priv->regmap, MESON_SAR_ADC_FIFO_RD, NULL);
>> >>       }
>> >>  }
>> >>
>> >
>>
>> Regards,
>> Martin
>

[toc] | [prev] | [next] | [standalone]


#1658522

FromPaolo Cretaro <paolocretaro@gmail.com>
Date2017-06-06 11:30 +0200
Message-ID<tPiYh-6PD-5@gated-at.bofh.it>
In reply to#1657072
Il 04/06/2017 15:32, Martin Blumenstingl ha scritto:
> Hi Paolo, Hi Jonathan,
> 
> On Sat, Jun 3, 2017 at 10:52 AM, Jonathan Cameron <jic23@kernel.org> wrote:
>> On Sun, 28 May 2017 23:17:57 +0200
>> Martin Blumenstingl <martin.blumenstingl@googlemail.com> wrote:
>>
>>> Hi Paolo, Hi Jonathan,
>>>
>>> On Sun, May 28, 2017 at 4:43 PM, Jonathan Cameron <jic23@kernel.org> wrote:
>>>> On Sun, 28 May 2017 13:24:38 +0200
>>>> Paolo Cretaro <paolocretaro@gmail.com> wrote:
>>>>
>>>>> Fix sparse warning: Using plain integer as NULL pointer
>>>>>
>>>>> Signed-off-by: Paolo Cretaro <paolocretaro@gmail.com>
>>>> This looks fine to me, but ideally you should always try to include
>>>> the driver author - particularly in the case of patches to a recent
>>>> driver such as this one.
>>>>
>>>> To that end I've cc'd Martin.
>>> thanks for spotting this (and providing a patch to fix it)
>>> this looks good to me, so:
>>> Acked-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
>>>
>>> if you can wait until next weekend then I can also test this on real hardware.
>> I've applied it to the togreg branch of iio.git but as that always goes out
>> as testing for at least a few days first (which I will happily rebase) give
>> me a shout if anything goes wrong!
> I have tested this on actual hardware and it seems that there's a bug
> in the meson-saradc driver (before and after this patch):
> if there are still "old" values in the FIFO then the driver currently
> crashes because regmap_read (regmap_mmio_read in case of the
> meson-saradc driver to be precise) de-references the "value" pointer
> (the parameter which we're trying to clean up here) -> this leads to a
> NULL de-reference. this happens regardless of whether we are passing
> "0" or "NULL"
> 
> I posted a patch which fixes the crash - and as a bonus this should
> also fix the sparse warning reported by Paolo:
> http://lists.infradead.org/pipermail/linux-amlogic/2017-June/003863.html
Nice, thanks!

Paolo
> 
>> Jonathan
>>>
>>>> Jonathan
>>>>> ---
>>>>>   drivers/iio/adc/meson_saradc.c | 2 +-
>>>>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>>>>
>>>>> diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c
>>>>> index 81cd39a57fe3..fb3f67a9ae1f 100644
>>>>> --- a/drivers/iio/adc/meson_saradc.c
>>>>> +++ b/drivers/iio/adc/meson_saradc.c
>>>>> @@ -481,7 +481,7 @@ static void meson_sar_adc_clear_fifo(struct iio_dev *indio_dev)
>>>>>                if (!meson_sar_adc_get_fifo_count(indio_dev))
>>>>>                        break;
>>>>>
>>>>> -             regmap_read(priv->regmap, MESON_SAR_ADC_FIFO_RD, 0);
>>>>> +             regmap_read(priv->regmap, MESON_SAR_ADC_FIFO_RD, NULL);
>>>>>        }
>>>>>   }
>>>>>
>>>>
>>>
>>> Regards,
>>> Martin
>>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web