* [PATCH] iio: adc: intel_mrfld_adc: Allocating too much data in probe()
@ 2019-11-19 6:21 Dan Carpenter
2019-11-19 10:23 ` Andy Shevchenko
0 siblings, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2019-11-19 6:21 UTC (permalink / raw)
To: Jonathan Cameron, Vincent Pelletier
Cc: Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler,
Andy Shevchenko, linux-iio, kernel-janitors
This probe function is passing the wrong size to devm_iio_device_alloc().
It is supposed to be the size of the private data. Fortunately,
sizeof(*indio_dev) is larger than sizeof(struct mrfld_adc) so it doesn't
cause a runtime problem.
Fixes: a7118662734a ("iio: adc: intel_mrfld_adc: Add Basin Cove ADC driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
drivers/iio/adc/intel_mrfld_adc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iio/adc/intel_mrfld_adc.c b/drivers/iio/adc/intel_mrfld_adc.c
index 67d096f8180d..c35a1beb817c 100644
--- a/drivers/iio/adc/intel_mrfld_adc.c
+++ b/drivers/iio/adc/intel_mrfld_adc.c
@@ -185,7 +185,7 @@ static int mrfld_adc_probe(struct platform_device *pdev)
int irq;
int ret;
- indio_dev = devm_iio_device_alloc(dev, sizeof(*indio_dev));
+ indio_dev = devm_iio_device_alloc(dev, sizeof(struct mrfld_adc));
if (!indio_dev)
return -ENOMEM;
--
2.11.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] iio: adc: intel_mrfld_adc: Allocating too much data in probe()
2019-11-19 6:21 [PATCH] iio: adc: intel_mrfld_adc: Allocating too much data in probe() Dan Carpenter
@ 2019-11-19 10:23 ` Andy Shevchenko
2019-11-23 14:42 ` Jonathan Cameron
0 siblings, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2019-11-19 10:23 UTC (permalink / raw)
To: Dan Carpenter
Cc: Jonathan Cameron, Vincent Pelletier, Hartmut Knaack,
Lars-Peter Clausen, Peter Meerwald-Stadler, linux-iio,
kernel-janitors
On Tue, Nov 19, 2019 at 09:21:24AM +0300, Dan Carpenter wrote:
> This probe function is passing the wrong size to devm_iio_device_alloc().
> It is supposed to be the size of the private data. Fortunately,
> sizeof(*indio_dev) is larger than sizeof(struct mrfld_adc) so it doesn't
> cause a runtime problem.
>
Ah, indeed, thanks for fixing this!
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Fixes: a7118662734a ("iio: adc: intel_mrfld_adc: Add Basin Cove ADC driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> drivers/iio/adc/intel_mrfld_adc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/adc/intel_mrfld_adc.c b/drivers/iio/adc/intel_mrfld_adc.c
> index 67d096f8180d..c35a1beb817c 100644
> --- a/drivers/iio/adc/intel_mrfld_adc.c
> +++ b/drivers/iio/adc/intel_mrfld_adc.c
> @@ -185,7 +185,7 @@ static int mrfld_adc_probe(struct platform_device *pdev)
> int irq;
> int ret;
>
> - indio_dev = devm_iio_device_alloc(dev, sizeof(*indio_dev));
> + indio_dev = devm_iio_device_alloc(dev, sizeof(struct mrfld_adc));
Many drivers use sizeof(*adc) form, but I'm okay with either.
> if (!indio_dev)
> return -ENOMEM;
>
> --
> 2.11.0
>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] iio: adc: intel_mrfld_adc: Allocating too much data in probe()
2019-11-19 10:23 ` Andy Shevchenko
@ 2019-11-23 14:42 ` Jonathan Cameron
2019-11-25 9:33 ` Andy Shevchenko
0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Cameron @ 2019-11-23 14:42 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Dan Carpenter, Vincent Pelletier, Hartmut Knaack,
Lars-Peter Clausen, Peter Meerwald-Stadler, linux-iio,
kernel-janitors
On Tue, 19 Nov 2019 12:23:32 +0200
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> On Tue, Nov 19, 2019 at 09:21:24AM +0300, Dan Carpenter wrote:
> > This probe function is passing the wrong size to devm_iio_device_alloc().
> > It is supposed to be the size of the private data. Fortunately,
> > sizeof(*indio_dev) is larger than sizeof(struct mrfld_adc) so it doesn't
> > cause a runtime problem.
> >
>
> Ah, indeed, thanks for fixing this!
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Applied to the fixes-togreg branch of iio.git.
I'll wait until after the merge window now to send a pull request for this
one so will be rc2ish before it's in.
Thanks,
Jonathan
>
> > Fixes: a7118662734a ("iio: adc: intel_mrfld_adc: Add Basin Cove ADC driver")
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > ---
> > drivers/iio/adc/intel_mrfld_adc.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/iio/adc/intel_mrfld_adc.c b/drivers/iio/adc/intel_mrfld_adc.c
> > index 67d096f8180d..c35a1beb817c 100644
> > --- a/drivers/iio/adc/intel_mrfld_adc.c
> > +++ b/drivers/iio/adc/intel_mrfld_adc.c
> > @@ -185,7 +185,7 @@ static int mrfld_adc_probe(struct platform_device *pdev)
> > int irq;
> > int ret;
> >
> > - indio_dev = devm_iio_device_alloc(dev, sizeof(*indio_dev));
> > + indio_dev = devm_iio_device_alloc(dev, sizeof(struct mrfld_adc));
>
> Many drivers use sizeof(*adc) form, but I'm okay with either.
>
> > if (!indio_dev)
> > return -ENOMEM;
> >
> > --
> > 2.11.0
> >
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] iio: adc: intel_mrfld_adc: Allocating too much data in probe()
2019-11-23 14:42 ` Jonathan Cameron
@ 2019-11-25 9:33 ` Andy Shevchenko
0 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2019-11-25 9:33 UTC (permalink / raw)
To: Jonathan Cameron
Cc: Dan Carpenter, Vincent Pelletier, Hartmut Knaack,
Lars-Peter Clausen, Peter Meerwald-Stadler, linux-iio,
kernel-janitors
On Sat, Nov 23, 2019 at 02:42:06PM +0000, Jonathan Cameron wrote:
> On Tue, 19 Nov 2019 12:23:32 +0200
> Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
>
> > On Tue, Nov 19, 2019 at 09:21:24AM +0300, Dan Carpenter wrote:
> > > This probe function is passing the wrong size to devm_iio_device_alloc().
> > > It is supposed to be the size of the private data. Fortunately,
> > > sizeof(*indio_dev) is larger than sizeof(struct mrfld_adc) so it doesn't
> > > cause a runtime problem.
> > >
> >
> > Ah, indeed, thanks for fixing this!
> > Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Applied to the fixes-togreg branch of iio.git.
Thanks!
> I'll wait until after the merge window now to send a pull request for this
> one so will be rc2ish before it's in.
Sure, as pointed out by Dan it seems to work due to size of wrong structure is
bigger than needed, thus it's not a critical fix.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, back to index
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-19 6:21 [PATCH] iio: adc: intel_mrfld_adc: Allocating too much data in probe() Dan Carpenter
2019-11-19 10:23 ` Andy Shevchenko
2019-11-23 14:42 ` Jonathan Cameron
2019-11-25 9:33 ` Andy Shevchenko
Linux-IIO Archive on lore.kernel.org
Archives are clonable:
git clone --mirror https://lore.kernel.org/linux-iio/0 linux-iio/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 linux-iio linux-iio/ https://lore.kernel.org/linux-iio \
linux-iio@vger.kernel.org
public-inbox-index linux-iio
Example config snippet for mirrors
Newsgroup available over NNTP:
nntp://nntp.lore.kernel.org/org.kernel.vger.linux-iio
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git