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  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <b6a54fdf-eb83-cf33-b3f9-d26d9be14d03@users.sourceforge.net>
Date:   Thu, 1 Feb 2018 17:58:27 +0100
From:   SF Markus Elfring <elfring@...rs.sourceforge.net>
To:     linux-i2c@...r.kernel.org, Till Harbaum <till@...baum.org>,
        Wolfram Sang <wsa@...-dreams.de>
Cc:     LKML <linux-kernel@...r.kernel.org>,
        kernel-janitors@...r.kernel.org
Subject: [PATCH 2/2] i2c-tiny-usb: Return an error code only as a constant in
 i2c_tiny_usb_probe()

From: Markus Elfring <elfring@...rs.sourceforge.net>
Date: Thu, 1 Feb 2018 17:45:21 +0100

* Return an error code without storing it in an intermediate variable.

* Delete the label "error" and local variable "retval"
  which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
---
 drivers/i2c/busses/i2c-tiny-usb.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/i2c/busses/i2c-tiny-usb.c b/drivers/i2c/busses/i2c-tiny-usb.c
index e210e36df123..2416bb0d8a88 100644
--- a/drivers/i2c/busses/i2c-tiny-usb.c
+++ b/drivers/i2c/busses/i2c-tiny-usb.c
@@ -223,7 +223,6 @@ static int i2c_tiny_usb_probe(struct usb_interface *interface,
 			      const struct usb_device_id *id)
 {
 	struct i2c_tiny_usb *dev;
-	int retval = -ENOMEM;
 	u16 version;
 
 	dev_dbg(&interface->dev, "probing usb device\n");
@@ -231,7 +230,7 @@ static int i2c_tiny_usb_probe(struct usb_interface *interface,
 	/* allocate memory for our device state and initialize it */
 	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
 	if (!dev)
-		goto error;
+		return -ENOMEM;
 
 	dev->usb_dev = usb_get_dev(interface_to_usbdev(interface));
 	dev->interface = interface;
@@ -257,8 +256,8 @@ static int i2c_tiny_usb_probe(struct usb_interface *interface,
 	if (usb_write(&dev->adapter, CMD_SET_DELAY, delay, 0, NULL, 0) != 0) {
 		dev_err(&dev->adapter.dev,
 			"failure setting delay to %dus\n", delay);
-		retval = -EIO;
-		goto error;
+		i2c_tiny_usb_free(dev);
+		return -EIO;
 	}
 
 	dev->adapter.dev.parent = &dev->interface->dev;
@@ -270,12 +269,6 @@ static int i2c_tiny_usb_probe(struct usb_interface *interface,
 	dev_info(&dev->adapter.dev, "connected i2c-tiny-usb device\n");
 
 	return 0;
-
- error:
-	if (dev)
-		i2c_tiny_usb_free(dev);
-
-	return retval;
 }
 
 static void i2c_tiny_usb_disconnect(struct usb_interface *interface)
-- 
2.16.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ