Skip to contentSkip to conversation

net: usb: Make init_satus() return -ENOMEM if alloc failed

PATCH In review Zqiang 4 participants 8 messages Jul 16, 2025 – Jul 21, 2025

Subsystems (4)
lore
Share & tools
lore

Zqiang

author
#0 lore raw

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
index 921c05bc73e3..26fce452581c 100644
@@ -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
author
#1 lore raw

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
index 6a3cca104af9..921c05bc73e3 100644
@@ -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
maintainer
#3 lore raw

Re: [PATCH] net: usb: Remove duplicate assignments for net->pcpu_stat_type

In reply to Zqiang
Quoted 1 line · On Wed, 16 Jul 2025 08:15:24 +0800 Zqiang wrote:

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
#4 lore raw

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

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
#5 lore raw

Re: [PATCH] net: usb: Remove duplicate assignments for net->pcpu_stat_type

In reply to Zqiang
This 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_type in usbnet_probe().

---
 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
reviewer
#6 lore raw
In reply to Zqiang
Quoted 4 lines · Zqiang

This commit make init_status() return -ENOMEM, if invoke kmalloc() return failed.

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?

#7 lore raw
Quoted 13 lines · Zqiang
Quoted 10 lines

This commit make init_status() return -ENOMEM, if invoke

kmalloc() return failed.

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

Quoted 1 line