net: usb: aqc111: fix set_mac_address return value for bonding
Subsystems (4)
PATCH 1/1 net: usb: aqc111: fix set_mac_address return value for bonding
aqc111_set_mac_addr() returns the result of aqc111_write_cmd() on success. That function wraps usb_control_msg(), which returns the number of bytes transferred (6 for ETH_ALEN) rather than zero.
Bonding calls ndo_set_mac_address() when enslaving an interface and treats any non-zero return value as failure.
Return 0 on success and propagate negative error codes on failure.
--- drivers/net/usb/aqc111.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/usb/aqc111.c +6 -2
@@ -471,8 +471,12 @@ static int aqc111_set_mac_addr(struct net_device *net, void *p)return ret;/* Set the MAC address */ -return aqc111_write_cmd (dev,AQ_ACCESS_MAC ,SFR_NODE_ID ,ETH_ALEN , -ETH_ALEN , net->dev_addr); + ret =aqc111_write_cmd (dev,AQ_ACCESS_MAC ,SFR_NODE_ID ,ETH_ALEN , +ETH_ALEN , net->dev_addr); +if (ret <0 ) +return ret; + +return 0 ; } static int aqc111_vlan_rx_kill_vid(struct net_device *net,
Signature · 1 line
2.34.1
Quoted 6 lines · Hanson Wang
aqc111_set_mac_addr()returns the result ofaqc111_write_cmd()on success. That function wrapsusb_control_msg(), which returns the number of bytes transferred (6 forETH_ALEN) rather than zero.Bonding calls
ndo_set_mac_address()when enslaving an interface and treats any non-zero return value as failure.
It is not just bonding which has problems:
int netif_set_mac_address(struct net_device *dev, struct sockaddr_storage *ss,
struct netlink_ext_ack *extack)
{
const struct net_device_ops *ops = dev->netdev_ops;
int err;
if (!ops->ndo_set_mac_address)
return -EOPNOTSUPP;
if (ss->ss_family != dev->type)
return -EINVAL;
if (!netif_device_present(dev))
return -ENODEV;
err = netif_pre_changeaddr_notify(dev, ss->__data, extack);
if (err)
return err;
if (memcmp(dev->dev_addr, ss->__data, dev->addr_len)) {
err = ops->ndo_set_mac_address(dev, ss);
if (err)
return err;Could you take a quick look at all USB ethernet drivers, and see if this bug exists in other drivers. If one driver has it wrong, it could well be more have it wrong.
Andrew
Hi Andrew,
Thanks for the review. You are right that this is not bonding-specific - any caller of ndo_set_mac_address() (including netif_set_mac_address() and "ip link set address") expects 0 on success and treats any non-zero return value as failure.
I audited all drivers under drivers/net/usb/ that implement a custom ndo_set_mac_address callback:
aqc111.c - BUG: returns usb_control_msg byte count (6) [this patch] ax88179_178a.c - OK: returns 0 after ax_write_cmd() asix_common.c - OK: returns 0 (async write to hardware) ch397.c - OK: returns 0 dm9601.c - OK: returns 0 (async write) lan78xx.c - OK: returns 0 mcs7830.c - OK: returns 0 qmi_wwan.c - OK: returns 0 r8152.c/r8157.c - OK: returns 0 on success (via usb_autopm_get_interface) rtl8150.c - OK: returns 0 sr9700.c - OK: returns 0 (async write) sr9800.c - OK: returns 0 (async write)
Drivers that use eth_mac_addr as ndo_set_mac_address (smsc95xx, smsc75xx, cdc_ncm, rndis, pegasus, usbnet default, etc.) always return 0 from the netdev op.
As far as I can tell, aqc111 is the only driver that directly returns the result of a USB control write without normalizing success to 0.
Please let me know if you would like any further changes to this patch.
Best regards,
Hanson Wang
Andrew Lunn
Reviewed-byQuoted 10 lines · Hanson Wang
Hi Andrew,
Thanks for the review. You are right that this is not bonding-specific - any caller of
ndo_set_mac_address()(includingnetif_set_mac_address()and "ip link set address") expects 0 on success and treats any non-zero return value as failure.I audited all drivers under
drivers/net/usb/that implement a customndo_set_mac_addresscallback:
Quoted 12 lines
aqc111.c - BUG: returns usb_control_msg byte count (6) [this patch] ax88179_178a.c - OK: returns 0 after ax_write_cmd() asix_common.c - OK: returns 0 (async write to hardware) ch397.c - OK: returns 0 dm9601.c - OK: returns 0 (async write) lan78xx.c - OK: returns 0 mcs7830.c - OK: returns 0 qmi_wwan.c - OK: returns 0 r8152.c/r8157.c - OK: returns 0 on success (via usb_autopm_get_interface) rtl8150.c - OK: returns 0 sr9700.c - OK: returns 0 (async write) sr9800.c - OK: returns 0 (async write)
Thanks for reviewing these drivers.
Andrew
Jakub Kicinski
maintainerdrivers/net/usb/aqc111.c static int aqc111_set_mac_addr(struct net_device *net, void *p) · line 475
Quoted 4 lines · On Fri, 3 Jul 2026 15:39:36 +0800 Hanson Wang wrote:
drivers/net/usb/aqc111.c +2
-2-return aqc111_write_cmd (dev,AQ_ACCESS_MAC ,SFR_NODE_ID ,ETH_ALEN , -ETH_ALEN , net->dev_addr); + ret =aqc111_write_cmd (dev,AQ_ACCESS_MAC ,SFR_NODE_ID ,ETH_ALEN , +ETH_ALEN , net->dev_addr);
nit: sashiko suggest the indent of the continuation line is off, which seems true. Please fix this and repost
PATCH v2 1/1 net: usb: aqc111: fix set_mac_address return value
In reply to Hanson Wangaqc111_set_mac_addr() returns the result of aqc111_write_cmd() on success. That function wraps usb_control_msg(), which returns the number of bytes transferred (6 for ETH_ALEN) rather than zero.
Callers such as netif_set_mac_address() and bonding treat any non-zero return value as failure when setting the MAC address.
Return 0 on success and propagate negative error codes on failure.
--- drivers/net/usb/aqc111.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/usb/aqc111.c +6 -2
@@ -476,8 +476,12 @@ static int aqc111_set_mac_addr(struct net_device *net, void *p)return ret;/* Set the MAC address */ -return aqc111_write_cmd (dev,AQ_ACCESS_MAC ,SFR_NODE_ID ,ETH_ALEN , -ETH_ALEN , net->dev_addr); + ret =aqc111_write_cmd (dev,AQ_ACCESS_MAC ,SFR_NODE_ID , +ETH_ALEN ,ETH_ALEN , net->dev_addr); +if (ret <0 ) +return ret; + +return 0 ; } static int aqc111_vlan_rx_kill_vid(struct net_device *net,
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH net v2] net: usb: aqc111: fix set_mac_address return value
This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
Hi!
This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan.
- Whether the issue was actually triggered, or is only theoretical (e.g. found by code inspection). If it was triggered please include the symptoms, like the stack trace or error messages.
Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account. If the series needs another revision for other reasons, please include the information in the commit messages then.
The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain.
[email protected]
AI reviewRe: [PATCH net v2] net: usb: aqc111: fix set_mac_address return value
In reply to Hanson WangSashiko has reviewed this patch and found no issues. It looks great!
Quoted 4 lines
aqc111_set_mac_addr()returns the result ofaqc111_write_cmd()on success. That function wrapsusb_control_msg(), which returns the number of bytes transferred (6 forETH_ALEN) rather than zero.
Quoted 8 lines
Callers such as
netif_set_mac_address()and bonding treat any non-zero return value as failure when setting the MAC address.Return 0 on success and propagate negative error codes on failure.
Signed-off-by Hanson Wang <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
PATCH v2 1/1 net: usb: aqc111: fix set_mac_address return value
In reply to Hanson Wangaqc111_set_mac_addr() returns the result of aqc111_write_cmd() on success. That function wraps usb_control_msg(), which returns the number of bytes transferred (6 for ETH_ALEN) rather than zero.
Callers such as netif_set_mac_address() and bonding treat any non-zero return value as failure when setting the MAC address.
Return 0 on success and propagate negative error codes on failure.
--- drivers/net/usb/aqc111.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/usb/aqc111.c +6 -2
@@ -476,8 +476,12 @@ static int aqc111_set_mac_addr(struct net_device *net, void *p)return ret;/* Set the MAC address */ -return aqc111_write_cmd (dev,AQ_ACCESS_MAC ,SFR_NODE_ID ,ETH_ALEN , -ETH_ALEN , net->dev_addr); + ret =aqc111_write_cmd (dev,AQ_ACCESS_MAC ,SFR_NODE_ID , +ETH_ALEN ,ETH_ALEN , net->dev_addr); +if (ret <0 ) +return ret; + +return 0 ; } static int aqc111_vlan_rx_kill_vid(struct net_device *net,
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH net v2] net: usb: aqc111: fix set_mac_address return value
This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
Hi!
This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan.
- Whether the issue was actually triggered, or is only theoretical (e.g. found by code inspection). If it was triggered please include the symptoms, like the stack trace or error messages.
Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account. If the series needs another revision for other reasons, please include the information in the commit messages then.
The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain.
[email protected]
AI reviewRe: [PATCH net v2] net: usb: aqc111: fix set_mac_address return value
In reply to Hanson WangSashiko has reviewed this patch and found no issues. It looks great!
Quoted 4 lines
aqc111_set_mac_addr()returns the result ofaqc111_write_cmd()on success. That function wrapsusb_control_msg(), which returns the number of bytes transferred (6 forETH_ALEN) rather than zero.
Quoted 8 lines
Callers such as
netif_set_mac_address()and bonding treat any non-zero return value as failure when setting the MAC address.Return 0 on success and propagate negative error codes on failure.
Signed-off-by Hanson Wang <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Re: [PATCH net v2] net: usb: aqc111: fix set_mac_address return value
In reply to Hanson WangQuoted 4 lines · Hanson Wang
aqc111_set_mac_addr()returns the result ofaqc111_write_cmd()on success. That function wrapsusb_control_msg(), which returns the number of bytes transferred (6 forETH_ALEN) rather than zero.
Quoted 8 lines
Callers such as
netif_set_mac_address()and bonding treat any non-zero return value as failure when setting the MAC address.Return 0 on success and propagate negative error codes on failure.
Signed-off-by Hanson Wang <[email protected]>
Overall this looks good to me, thanks for your contribution.
Some points on process to keep in mind.
There is no need to repost to address these.
1. Please respond to netdev-bot+sinfo.
It's not too late to do so!
https://lore.kernel.org/netdev/[email protected]/
2. Please post new versions to patches in new email threads, not as a reply to an earlier versions.
3. Please don't repost within 24h.
4. Please don't repost the same version, without either incrementing the version number or including repost in the subject.
[PATCh net v2 repost] ...
5. Please do include a summary of what has changed below the scissors ('---'). Ideally including lore.kernel.org links to earlier versions.
v2: Fixes indentation
v1: https://lore.kernel.org/netdev/[email protected]/
6. Please don't use the Link tag to link to an earlier version. Instead use it if there is some extra information, e.g. an otherwise unrelated email thread that lead to this patch.
For more information on Netdev processes please see
https://docs.kernel.org/process/maintainer-netdev.html
Re: [PATCH net v2] net: usb: aqc111: fix set_mac_address return value
In reply to Hanson WangThis patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Fri, 16 Oct 2026 20:48:58 +0800 you wrote:
aqc111_set_mac_addr()returns the result ofaqc111_write_cmd()on success. That function wrapsusb_control_msg(), which returns the number of bytes transferred (6 forETH_ALEN) rather than zero.Callers such as
netif_set_mac_address()and bonding treat any non-zero return value as failure when setting the MAC address.[...]
Here is the summary with links:
- [net,v2] net: usb: aqc111: fix set_mac_address return value
https://git.kernel.org/netdev/net/c/c3a1ddd5e116
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html