iio: adc: Check for error from devm_mutex_init()
Subsystems (4)
cover iio: adc: Check for error from devm_mutex_init()
Ignoring error checking from devm calls is a bad practice in general. While not critical today, it may become a problem tomorrow. Fix this for devm_mutex_init().
Andy Shevchenko (2):
iio: adc: ad4000: Check for error code from devm_mutex_init() call
iio: adc: pac1921: Check for error code from devm_mutex_init() call
drivers/iio/adc/ad4000.c | 4 +++- drivers/iio/adc/pac1921.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-)
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
PATCH 1/2 iio: adc: ad4000: Check for error code from devm_mutex_init() call
Even if it's not critical, the avoidance of checking the error code from devm_mutex_init() call today diminishes the point of using devm variant of it. Tomorrow it may even leak something. Add the missed check.
--- drivers/iio/adc/ad4000.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iio/adc/ad4000.c +3 -1
@@ -637,7 +637,9 @@ static int ad4000_probe(struct spi_device *spi) indio_dev->name = chip->dev_name; indio_dev->num_channels =1 ; -devm_mutex_init (dev, &st->lock); + ret =devm_mutex_init (dev, &st->lock); +if (ret) +return ret; st->gain_milli =1000 ;if (chip->has_hardware_gain) {
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
PATCH 2/2 iio: adc: pac1921: Check for error code from devm_mutex_init() call
In reply to Andy ShevchenkoEven if it's not critical, the avoidance of checking the error code from devm_mutex_init() call today diminishes the point of using devm variant of it. Tomorrow it may even leak something. Add the missed check.
--- drivers/iio/adc/pac1921.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iio/adc/pac1921.c +3 -1
@@ -1132,7 +1132,9 @@ static int pac1921_probe(struct i2c_client *client)return dev_err_probe (dev,PTR_ERR (priv->regmap),"Cannot initialize register map\n" ); -devm_mutex_init (dev, &priv->lock); + ret =devm_mutex_init (dev, &priv->lock); +if (ret) +return ret; priv->dv_gain =PAC1921_DEFAULT_DV_GAIN ; priv->di_gain =PAC1921_DEFAULT_DI_GAIN ;
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
Re: [PATCH v1 2/2] iio: adc: pac1921: Check for error code from devm_mutex_init() call
Quoting Andy Shevchenko (2024-10-30 17:19:19)
Quoted 29 lines
Even if it's not critical, the avoidance of checking the error code from
devm_mutex_init()call today diminishes the point of using devm variant of it. Tomorrow it may even leak something. Add the missed check.Fixes 371f778b83cd ("iio: adc: add support for pac1921")Signed-off-by Andy Shevchenko <[email protected]>--- drivers/iio/adc/pac1921.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/iio/adc/pac1921.c +3
-1@@ -1132,7 +1132,9 @@ static int pac1921_probe(struct i2c_client *client)return dev_err_probe (dev,PTR_ERR (priv->regmap),"Cannot initialize register map\n" ); -devm_mutex_init (dev, &priv->lock); + ret =devm_mutex_init (dev, &priv->lock); +if (ret) +return ret; priv->dv_gain =PAC1921_DEFAULT_DV_GAIN ; priv->di_gain =PAC1921_DEFAULT_DI_GAIN ;Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
Totally agree, thanks!
Best regards,
Matteo Martelli
Quoted 8 lines · On Wed, 30 Oct 2024 18:19:17 +0200 Andy Shevchenko…
Ignoring error checking from devm calls is a bad practice in general. While not critical today, it may become a problem tomorrow. Fix this for
devm_mutex_init().Andy Shevchenko (2):
iio: adc: ad4000: Check for error code fromdevm_mutex_init()call
iio: adc: pac1921: Check for error code fromdevm_mutex_init()call
Oops. Missed this in review obviously.
Applied.
Quoted 4 lines
drivers/iio/adc/ad4000.c | 4 +++- drivers/iio/adc/pac1921.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-)