lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 26 Oct 2017 10:40:12 +0200
From:   SF Markus Elfring <elfring@...rs.sourceforge.net>
To:     linux-iio@...r.kernel.org, Akinobu Mita <akinobu.mita@...il.com>,
        Crestez Dan Leonard <leonard.crestez@...el.com>,
        Hartmut Knaack <knaack.h@....de>,
        Jonathan Cameron <jic23@...nel.org>,
        Lars-Peter Clausen <lars@...afoo.de>,
        Peter Meerwald-Stadler <pmeerw@...erw.net>
Cc:     LKML <linux-kernel@...r.kernel.org>,
        kernel-janitors@...r.kernel.org
Subject: [PATCH] iio/light/max44000: Use common error handling code in
 max44000_probe()

From: Markus Elfring <elfring@...rs.sourceforge.net>
Date: Thu, 26 Oct 2017 10:30:57 +0200

* Add a jump target so that a specific error message is stored only once
  at the end of this function implementation.

* Replace two calls of the function "dev_err" by goto statements.

* Adjust condition checks.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
---
 drivers/iio/light/max44000.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/iio/light/max44000.c b/drivers/iio/light/max44000.c
index bcdb0eb9e537..8f4bc6a918d5 100644
--- a/drivers/iio/light/max44000.c
+++ b/drivers/iio/light/max44000.c
@@ -569,18 +569,14 @@ static int max44000_probe(struct i2c_client *client,
 	 * Set a middle value so that we get some sort of valid data by default.
 	 */
 	ret = max44000_write_led_current_raw(data, MAX44000_LED_CURRENT_DEFAULT);
-	if (ret < 0) {
-		dev_err(&client->dev, "failed to write init config: %d\n", ret);
-		return ret;
-	}
+	if (ret)
+		goto report_failure;
 
 	/* Reset CFG bits to ALS_PRX mode which allows easy reading of both values. */
 	reg = MAX44000_CFG_TRIM | MAX44000_CFG_MODE_ALS_PRX;
 	ret = regmap_write(data->regmap, MAX44000_REG_CFG_MAIN, reg);
-	if (ret < 0) {
-		dev_err(&client->dev, "failed to write init config: %d\n", ret);
-		return ret;
-	}
+	if (ret)
+		goto report_failure;
 
 	/* Read status at least once to clear any stale interrupt bits. */
 	ret = regmap_read(data->regmap, MAX44000_REG_STATUS, &reg);
@@ -596,6 +592,10 @@ static int max44000_probe(struct i2c_client *client,
 	}
 
 	return iio_device_register(indio_dev);
+
+report_failure:
+	dev_err(&client->dev, "failed to write init config: %d\n", ret);
+	return ret;
 }
 
 static int max44000_remove(struct i2c_client *client)
-- 
2.14.3

Powered by blists - more mailing lists