mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net-next] net: usb: ax88172a: improve MAC address read error handling
@ 2026-09-28  4:40 Xinsheng Zhu
  2026-09-28 16:59 ` Andrew Lunn
  2026-09-30 23:40 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Xinsheng Zhu @ 2026-09-28  4:40 UTC (permalink / raw)
  To: netdev
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni, linux-usb, linux-kernel

When retrieving the MAC address, ax88172a_bind() checks the return
value of asix_read_cmd() against ETH_ALEN to detect short reads.
Commit c28d9a285668 ("ax88172a: fix ax88172a_unbind() failures") added
an -EIO assignment to ensure that this failure path returns a negative
error code, even when asix_read_cmd() returns a non-negative short-read
length.

Short-read handling was subsequently added to asix_read_cmd() by commit
920a9fa27e78 ("net: asix: add proper error handling of usb read errors").
The helper now converts short reads to -ENODATA while preserving
negative errors from the underlying USB read operation.

The MAC address short-read check in ax88172a_bind() is therefore
redundant now, and overwriting the return value with -EIO is no longer
necessary to ensure that the failure path returns a negative error code.

Check only for negative return values and remove the -EIO assignment
to preserve the error returned by asix_read_cmd() through the existing
cleanup path.

Signed-off-by: Xinsheng Zhu <xinsheng.zhu.ny@gmail.com>
---
 drivers/net/usb/ax88172a.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/usb/ax88172a.c b/drivers/net/usb/ax88172a.c
index 6b14bce2a552..f5036451f086 100644
--- a/drivers/net/usb/ax88172a.c
+++ b/drivers/net/usb/ax88172a.c
@@ -173,9 +173,8 @@ static int ax88172a_bind(struct usbnet *dev, struct usb_interface *intf)
 
 	/* Get the MAC address */
 	ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf, 0);
-	if (ret < ETH_ALEN) {
+	if (ret < 0) {
 		netdev_err(dev->net, "Failed to read MAC address: %d\n", ret);
-		ret = -EIO;
 		goto free;
 	}
 	eth_hw_addr_set(dev->net, buf);

base-commit: 014d795c73837ea2339a4ea8e8f82c6e959b845d
-- 
2.54.0 (Apple Git-157)


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] net: usb: ax88172a: improve MAC address read error handling
  2026-09-28  4:40 [PATCH net-next] net: usb: ax88172a: improve MAC address read error handling Xinsheng Zhu
@ 2026-09-28 16:59 ` Andrew Lunn
  2026-09-30 23:40 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Lunn @ 2026-09-28 16:59 UTC (permalink / raw)
  To: Xinsheng Zhu
  Cc: netdev, andrew+netdev, davem, edumazet, kuba, pabeni, linux-usb,
	linux-kernel

On Mon, Sep 28, 2026 at 12:40:11AM -0400, Xinsheng Zhu wrote:
> When retrieving the MAC address, ax88172a_bind() checks the return
> value of asix_read_cmd() against ETH_ALEN to detect short reads.
> Commit c28d9a285668 ("ax88172a: fix ax88172a_unbind() failures") added
> an -EIO assignment to ensure that this failure path returns a negative
> error code, even when asix_read_cmd() returns a non-negative short-read
> length.
> 
> Short-read handling was subsequently added to asix_read_cmd() by commit
> 920a9fa27e78 ("net: asix: add proper error handling of usb read errors").
> The helper now converts short reads to -ENODATA while preserving
> negative errors from the underlying USB read operation.
> 
> The MAC address short-read check in ax88172a_bind() is therefore
> redundant now, and overwriting the return value with -EIO is no longer
> necessary to ensure that the failure path returns a negative error code.
> 
> Check only for negative return values and remove the -EIO assignment
> to preserve the error returned by asix_read_cmd() through the existing
> cleanup path.
> 
> Signed-off-by: Xinsheng Zhu <xinsheng.zhu.ny@gmail.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] net: usb: ax88172a: improve MAC address read error handling
  2026-09-28  4:40 [PATCH net-next] net: usb: ax88172a: improve MAC address read error handling Xinsheng Zhu
  2026-09-28 16:59 ` Andrew Lunn
@ 2026-09-30 23:40 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-09-30 23:40 UTC (permalink / raw)
  To: Xinsheng Zhu
  Cc: netdev, andrew+netdev, davem, edumazet, kuba, pabeni, linux-usb,
	linux-kernel

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Mon, 28 Sep 2026 00:40:11 -0400 you wrote:
> When retrieving the MAC address, ax88172a_bind() checks the return
> value of asix_read_cmd() against ETH_ALEN to detect short reads.
> Commit c28d9a285668 ("ax88172a: fix ax88172a_unbind() failures") added
> an -EIO assignment to ensure that this failure path returns a negative
> error code, even when asix_read_cmd() returns a non-negative short-read
> length.
> 
> [...]

Here is the summary with links:
  - [net-next] net: usb: ax88172a: improve MAC address read error handling
    https://git.kernel.org/netdev/net-next/c/b38dd3a0cf1d

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-09-30 23:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-28  4:40 [PATCH net-next] net: usb: ax88172a: improve MAC address read error handling Xinsheng Zhu
2026-09-28 16:59 ` Andrew Lunn
2026-09-30 23:40 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®