diff mbox series

[net] net: asix: Add check for usbnet_get_endpoints

Message ID 20240320073715.2002973-1-nichen@iscas.ac.cn (mailing list archive)
State New, archived
Headers show
Series [net] net: asix: Add check for usbnet_get_endpoints | expand

Commit Message

Chen Ni March 20, 2024, 7:37 a.m. UTC
Add check for usbnet_get_endpoints() and return the error if it fails
in order to transfer the error.

Fixes: b4cdae20ef95 ("asix: Rename asix.c to asix_devices.c")
Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
---
 drivers/net/usb/asix_devices.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

Comments

Jiri Pirko March 20, 2024, 1:25 p.m. UTC | #1
Wed, Mar 20, 2024 at 08:37:15AM CET, nichen@iscas.ac.cn wrote:
>Add check for usbnet_get_endpoints() and return the error if it fails
>in order to transfer the error.
>
>Fixes: b4cdae20ef95 ("asix: Rename asix.c to asix_devices.c")

Are you sure this is the commit that introduced this? Too lazy to look,
but most probably this just moved already buggy code.


>Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
>---
> drivers/net/usb/asix_devices.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
>diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
>index f7cff58fe044..4732a2951bf2 100644
>--- a/drivers/net/usb/asix_devices.c
>+++ b/drivers/net/usb/asix_devices.c
>@@ -230,7 +230,9 @@ static int ax88172_bind(struct usbnet *dev, struct usb_interface *intf)
> 	int i;
> 	unsigned long gpio_bits = dev->driver_info->data;
> 
>-	usbnet_get_endpoints(dev,intf);
>+	ret = usbnet_get_endpoints(dev, intf);
>+	if (ret < 0)

I don't think that usbnet_get_endpoints() can return positive value.
Better to have just:
	ret = usbnet_get_endpoints(dev, intf);
	if (ret)


>+		goto out;

just "return ret" here. I know that the rest of the function does this
too, don't copy odd pattern.


> 
> 	/* Toggle the GPIOs in a manufacturer/model specific way */
> 	for (i = 2; i >= 0; i--) {
>@@ -834,7 +836,9 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
> 
> 	dev->driver_priv = priv;
> 
>-	usbnet_get_endpoints(dev, intf);
>+	ret = usbnet_get_endpoints(dev, intf);
>+	if (ret < 0)
>+		return ret;
> 
> 	/* Maybe the boot loader passed the MAC address via device tree */
> 	if (!eth_platform_get_mac_address(&dev->udev->dev, buf)) {
>@@ -1258,7 +1262,9 @@ static int ax88178_bind(struct usbnet *dev, struct usb_interface *intf)
> 	int ret;
> 	u8 buf[ETH_ALEN] = {0};
> 
>-	usbnet_get_endpoints(dev,intf);
>+	ret = usbnet_get_endpoints(dev, intf);
>+	if (ret < 0)
>+		return ret;
> 
> 	/* Get the MAC address */
> 	ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf, 0);
>-- 
>2.25.1
>
>
diff mbox series

Patch

diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
index f7cff58fe044..4732a2951bf2 100644
--- a/drivers/net/usb/asix_devices.c
+++ b/drivers/net/usb/asix_devices.c
@@ -230,7 +230,9 @@  static int ax88172_bind(struct usbnet *dev, struct usb_interface *intf)
 	int i;
 	unsigned long gpio_bits = dev->driver_info->data;
 
-	usbnet_get_endpoints(dev,intf);
+	ret = usbnet_get_endpoints(dev, intf);
+	if (ret < 0)
+		goto out;
 
 	/* Toggle the GPIOs in a manufacturer/model specific way */
 	for (i = 2; i >= 0; i--) {
@@ -834,7 +836,9 @@  static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
 
 	dev->driver_priv = priv;
 
-	usbnet_get_endpoints(dev, intf);
+	ret = usbnet_get_endpoints(dev, intf);
+	if (ret < 0)
+		return ret;
 
 	/* Maybe the boot loader passed the MAC address via device tree */
 	if (!eth_platform_get_mac_address(&dev->udev->dev, buf)) {
@@ -1258,7 +1262,9 @@  static int ax88178_bind(struct usbnet *dev, struct usb_interface *intf)
 	int ret;
 	u8 buf[ETH_ALEN] = {0};
 
-	usbnet_get_endpoints(dev,intf);
+	ret = usbnet_get_endpoints(dev, intf);
+	if (ret < 0)
+		return ret;
 
 	/* Get the MAC address */
 	ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf, 0);