net: usb: Make init_satus() return -ENOMEM if alloc failed
PATCH 1/1 net: usb: Make init_satus() return -ENOMEM if alloc failed
This commit make init_status() return -ENOMEM, if invoke kmalloc() return failed.
--- drivers/net/usb/usbnet.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/usb/usbnet.c +2 -0
@@ -254,6 +254,8 @@ static int init_status (struct usbnet *dev, struct usb_interface *intf)"status ep%din, %d bytes period %d\n" , usb_pipeendpoint(pipe), maxp, period); } + }else { +return -ENOMEM ; }return 0 ; }
Signature · 1 line
2.48.1
PATCH 1/1 net: usb: Remove duplicate assignments for net->pcpu_stat_type
This commit remove duplicate assignments for net->pcpu_stat_type in usbnet_probe().
--- drivers/net/usb/usbnet.c | 1 - 1 file changed, 1 deletion(-)
drivers/net/usb/usbnet.c +0 -1
@@ -1759,7 +1759,6 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod) dev->hard_mtu = net->mtu + net->hard_header_len; net->min_mtu =0 ; net->max_mtu =ETH_MAX_MTU ; - net->pcpu_stat_type =NETDEV_PCPU_STAT_TSTATS ; net->netdev_ops = &usbnet_netdev_ops; net->watchdog_timeo =TX_TIMEOUT_JIFFIES ;
Signature · 1 line
2.48.1
Re: [PATCH] net: usb: Remove duplicate assignments for net->pcpu_stat_type
Quoted 4 lines · Zqiang
This commit remove duplicate assignments for
net->pcpu_stat_typeinusbnet_probe().Signed-off-by Zqiang <[email protected]>
This one looks good, thanks.
Jakub Kicinski
maintainerRe: [PATCH] net: usb: Remove duplicate assignments for net->pcpu_stat_type
In reply to ZqiangQuoted 1 line · On Wed, 16 Jul 2025 08:15:24 +0800 Zqiang wrote:
Signed-off-by Zqiang <[email protected]>
Your email address seems to suggest the latin spelling of your name should be Qiang Zhang. Please use that instead of Zqiang?
Signature · 1 line
pw-bot: cr
Re: [PATCH] net: usb: Remove duplicate assignments for net->pcpu_stat_type
Quoted 10 lines · On Wed, 16 Jul 2025 08:15:24 +0800 Zqiang wrote:
Quoted 4 lines
Signed-off-by Zqiang <[email protected]>Your email address seems to suggest the latin spelling of your name
should be Qiang Zhang. Please use that instead of Zqiang?
Thanks for replay, Zqiang has always been the name I use in my life and in the community.
Thanks
Zqiang
Quoted 5 lines
Signature · 3 lines
-- pw-bot: cr
Re: [PATCH] net: usb: Remove duplicate assignments for net->pcpu_stat_type
In reply to ZqiangThis patch was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:
Quoted 7 lines · On Wed, 16 Jul 2025 08:15:24 +0800 you wrote:
This commit remove duplicate assignments for
net->pcpu_stat_typeinusbnet_probe().Signed-off-by Zqiang <[email protected]>--- drivers/net/usb/usbnet.c | 1 - 1 file changed, 1 deletion(-)
Here is the summary with links:
- net: usb: Remove duplicate assignments for net->pcpu_stat_type
https://git.kernel.org/netdev/net-next/c/dd500e4aecf2
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
Simon Horman
reviewerQuoted 4 lines · Zqiang
This commit make
init_status()return-ENOMEM, if invokekmalloc()return failed.Signed-off-by Zqiang <[email protected]>
Hi,
It seems to me that the code has been structured so that this case is not treated as an error, and rather initialisation that depends on it is skipped.
Are you sure this change is correct?
Quoted 13 lines · Zqiang
Quoted 10 lines
This commit make
init_status()return-ENOMEM, if invoke
kmalloc()return failed.Signed-off-by Zqiang <[email protected]>
Quoted 7 lines
Hi,
It seems to me that the code has been structured so that
this case is not treated as an error, and rather initialisation
that depends on it is skipped.
Yes, your point is also correct, but in theory,
if usb_alloc_urb() allocation fails, we should
also return a value of 0, should we keep the
two behaviors consistent?
Quoted 2 lines
Are you sure this change is correct?
For drivers that have a driver_info->status method, it is generally needto allocate an interrupt urb and fill it to obtain some status information, but if kmalloc() faild and return 0 in init_status(), and some dirvers directly call usbnet_status_start(),
the WARN_ONCE(dev->interrupt == NULL) will be trigger.
Thanks
Zqiang