Skip to contentSkip to conversation

staging: iio: ad9834: add a check for devm_clk_get

PATCH In review Chuhong Yuan 4 participants 4 messages Oct 16, 2019 – Oct 18, 2019

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: iio: ad9834: add a check for devm_clk_get

ad9834_probe misses a check for devm_clk_get and may cause problems. Add a check like what ad9832 does to fix it.

---
 drivers/staging/iio/frequency/ad9834.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/staging/iio/frequency/ad9834.c +4 -0
index 038d6732c3fd..23026978a5a5 100644
@@ -417,6 +417,10 @@ static int ad9834_probe(struct spi_device *spi)
 	st = iio_priv(indio_dev);
 	mutex_init(&st->lock);
 	st->mclk = devm_clk_get(&spi->dev, NULL);
+	if (IS_ERR(st->mclk)) {
+		ret = PTR_ERR(st->mclk);
+		goto error_disable_reg;
+	}
 
 	ret = clk_prepare_enable(st->mclk);
 	if (ret) {
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#2 lore raw
In reply to Chuhong Yuan
Quoted 3 lines · Chuhong Yuan

ad9834_probe misses a check for devm_clk_get and may cause problems. Add a check like what ad9832 does to fix it.

This could also use a Fixes tag, but not a big deal.

Quoted 21 lines
---
 drivers/staging/iio/frequency/ad9834.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/staging/iio/frequency/ad9834.c +4 -0
index 038d6732c3fd..23026978a5a5 100644
@@ -417,6 +417,10 @@ static int ad9834_probe(struct spi_device *spi)
 	st = iio_priv(indio_dev);
 	mutex_init(&st->lock);
 	st->mclk = devm_clk_get(&spi->dev, NULL);
+	if (IS_ERR(st->mclk)) {
+		ret = PTR_ERR(st->mclk);
+		goto error_disable_reg;
+	}
 
 	ret = clk_prepare_enable(st->mclk);
 	if (ret) {
maintainer
#3 lore raw
Quoted 8 lines · Alexandru
Quoted 3 lines · Chuhong Yuan

ad9834_probe misses a check for devm_clk_get and may cause problems. Add a check like what ad9832 does to fix it.

This could also use a Fixes tag, but not a big deal.

Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it.

As a general point though, the fact that a devm error handler actually has things to do suggests this code doesn't pass the obviously correct test.

Nothing to do with this patch mind you!

Jonathan

Quoted 22 lines
Quoted 22 lines
---
 drivers/staging/iio/frequency/ad9834.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/staging/iio/frequency/ad9834.c +4 -0
index 038d6732c3fd..23026978a5a5 100644
@@ -417,6 +417,10 @@ static int ad9834_probe(struct spi_device *spi)
 	st = iio_priv(indio_dev);
 	mutex_init(&st->lock);
 	st->mclk = devm_clk_get(&spi->dev, NULL);
+	if (IS_ERR(st->mclk)) {
+		ret = PTR_ERR(st->mclk);
+		goto error_disable_reg;
+	}
 
 	ret = clk_prepare_enable(st->mclk);
 	if (ret) {