summaryrefslogtreecommitdiffstats
path: root/drivers/iio
diff options
context:
space:
mode:
authorNicholas Mc Guire <hofrat@osadl.org>2018-11-22 08:46:43 +0100
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2018-11-25 10:38:36 +0000
commitaad172b017617994343e36d8659c69e14cd694fd (patch)
treeef15541184983a031b33e815217aa9111e80e695 /drivers/iio
parentbac257b0d2a1e06426f7db56abeda7c2ffcf0752 (diff)
downloadlinux-aad172b017617994343e36d8659c69e14cd694fd.tar.bz2
iio: adc: meson-saradc: check for devm_kasprintf failure
devm_kasprintf() may return NULL on failure of internal allocation thus the assignments to init.name are not safe if not checked. On error meson_sar_adc_clk_init() returns negative values so -ENOMEM in the (unlikely) failure case of devm_kasprintf() should be fine here. Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org> Fixes: 3adbf3427330 ("iio: adc: add a driver for the SAR ADC found in Amlogic Meson SoCs") Acked-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> Tested-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio')
-rw-r--r--drivers/iio/adc/meson_saradc.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c
index 26011254ffbc..6155d26091eb 100644
--- a/drivers/iio/adc/meson_saradc.c
+++ b/drivers/iio/adc/meson_saradc.c
@@ -658,6 +658,9 @@ static int meson_sar_adc_clk_init(struct iio_dev *indio_dev,
init.name = devm_kasprintf(&indio_dev->dev, GFP_KERNEL, "%pOF#adc_div",
indio_dev->dev.of_node);
+ if (!init.name)
+ return -ENOMEM;
+
init.flags = 0;
init.ops = &clk_divider_ops;
clk_parents[0] = __clk_get_name(priv->clkin);
@@ -677,6 +680,9 @@ static int meson_sar_adc_clk_init(struct iio_dev *indio_dev,
init.name = devm_kasprintf(&indio_dev->dev, GFP_KERNEL, "%pOF#adc_en",
indio_dev->dev.of_node);
+ if (!init.name)
+ return -ENOMEM;
+
init.flags = CLK_SET_RATE_PARENT;
init.ops = &clk_gate_ops;
clk_parents[0] = __clk_get_name(priv->adc_div_clk);