iio: adc: intel_mrfld_adc: Allocating too much data in probe()

This change “iio: adc: intel_mrfld_adc: Allocating too much data in probe()” (commit 1f310f7) in Linux kernel is authored by Dan Carpenter <dan.carpenter [at] oracle.com> on Tue Nov 19 09:21:24 2019 +0300.

Description of "iio: adc: intel_mrfld_adc: Allocating too much data in probe()"

The change “iio: adc: intel_mrfld_adc: Allocating too much data in probe()” introduces changes as follows.

iio: adc: intel_mrfld_adc: Allocating too much data in probe()

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>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Linux kernel releases containing commit 1f310f7

The Linux kernel releases containing this commit are as follows.

Linux kernel code changes from "iio: adc: intel_mrfld_adc: Allocating too much data in probe()"

There are 2 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 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;
 

The commit for this change in Linux stable tree is 1f310f7 (patch).

Last modified: 2020/02/08