netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: usb: Make init_satus() return -ENOMEM if alloc failed
@ 2025-07-16  0:15 Zqiang
  2025-07-16  0:15 ` [PATCH] net: usb: Remove duplicate assignments for net->pcpu_stat_type Zqiang
  2025-07-16  9:18 ` [PATCH] net: usb: Make init_satus() return -ENOMEM if alloc failed Simon Horman
  0 siblings, 2 replies; 8+ messages in thread
From: Zqiang @ 2025-07-16  0:15 UTC (permalink / raw)
  To: oneukum, kuba, andrew+netdev, davem, pabeni
  Cc: qiang.zhang, netdev, linux-kernel

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

Signed-off-by: Zqiang <qiang.zhang@linux.dev>
---
 drivers/net/usb/usbnet.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 921c05bc73e3..26fce452581c 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -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;
 }
-- 
2.48.1


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

* [PATCH] net: usb: Remove duplicate assignments for net->pcpu_stat_type
  2025-07-16  0:15 [PATCH] net: usb: Make init_satus() return -ENOMEM if alloc failed Zqiang
@ 2025-07-16  0:15 ` Zqiang
  2025-07-16  9:19   ` Simon Horman
                     ` (2 more replies)
  2025-07-16  9:18 ` [PATCH] net: usb: Make init_satus() return -ENOMEM if alloc failed Simon Horman
  1 sibling, 3 replies; 8+ messages in thread
From: Zqiang @ 2025-07-16  0:15 UTC (permalink / raw)
  To: oneukum, kuba, andrew+netdev, davem, pabeni
  Cc: qiang.zhang, netdev, linux-kernel

This commit remove duplicate assignments for net->pcpu_stat_type
in usbnet_probe().

Signed-off-by: Zqiang <qiang.zhang@linux.dev>
---
 drivers/net/usb/usbnet.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 6a3cca104af9..921c05bc73e3 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -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;
-- 
2.48.1


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

* Re: [PATCH] net: usb: Make init_satus() return -ENOMEM if alloc failed
  2025-07-16  0:15 [PATCH] net: usb: Make init_satus() return -ENOMEM if alloc failed Zqiang
  2025-07-16  0:15 ` [PATCH] net: usb: Remove duplicate assignments for net->pcpu_stat_type Zqiang
@ 2025-07-16  9:18 ` Simon Horman
  2025-07-17  0:04   ` qiang.zhang
  1 sibling, 1 reply; 8+ messages in thread
From: Simon Horman @ 2025-07-16  9:18 UTC (permalink / raw)
  To: Zqiang; +Cc: oneukum, kuba, andrew+netdev, davem, pabeni, netdev, linux-kernel

On Wed, Jul 16, 2025 at 08:15:23AM +0800, Zqiang wrote:
> This commit make init_status() return -ENOMEM, if invoke
> kmalloc() return failed.
> 
> Signed-off-by: Zqiang <qiang.zhang@linux.dev>

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?

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

* Re: [PATCH] net: usb: Remove duplicate assignments for net->pcpu_stat_type
  2025-07-16  0:15 ` [PATCH] net: usb: Remove duplicate assignments for net->pcpu_stat_type Zqiang
@ 2025-07-16  9:19   ` Simon Horman
  2025-07-16 22:11   ` Jakub Kicinski
  2025-07-21  9:50   ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 8+ messages in thread
From: Simon Horman @ 2025-07-16  9:19 UTC (permalink / raw)
  To: Zqiang; +Cc: oneukum, kuba, andrew+netdev, davem, pabeni, netdev, linux-kernel

On Wed, Jul 16, 2025 at 08:15:24AM +0800, Zqiang wrote:
> This commit remove duplicate assignments for net->pcpu_stat_type
> in usbnet_probe().
> 
> Signed-off-by: Zqiang <qiang.zhang@linux.dev>

This one looks good, thanks.

Reviewed-by: Simon Horman <horms@kernel.org>

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

* Re: [PATCH] net: usb: Remove duplicate assignments for net->pcpu_stat_type
  2025-07-16  0:15 ` [PATCH] net: usb: Remove duplicate assignments for net->pcpu_stat_type Zqiang
  2025-07-16  9:19   ` Simon Horman
@ 2025-07-16 22:11   ` Jakub Kicinski
  2025-07-17  0:08     ` qiang.zhang
  2025-07-21  9:50   ` patchwork-bot+netdevbpf
  2 siblings, 1 reply; 8+ messages in thread
From: Jakub Kicinski @ 2025-07-16 22:11 UTC (permalink / raw)
  To: Zqiang; +Cc: oneukum, andrew+netdev, davem, pabeni, netdev, linux-kernel

On Wed, 16 Jul 2025 08:15:24 +0800 Zqiang wrote:
> Signed-off-by: Zqiang <qiang.zhang@linux.dev>

Your email address seems to suggest the latin spelling of your name
should be Qiang Zhang. Please use that instead of Zqiang?
-- 
pw-bot: cr

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

* Re: [PATCH] net: usb: Make init_satus() return -ENOMEM if alloc failed
  2025-07-16  9:18 ` [PATCH] net: usb: Make init_satus() return -ENOMEM if alloc failed Simon Horman
@ 2025-07-17  0:04   ` qiang.zhang
  0 siblings, 0 replies; 8+ messages in thread
From: qiang.zhang @ 2025-07-17  0:04 UTC (permalink / raw)
  To: Simon Horman
  Cc: oneukum, kuba, andrew+netdev, davem, pabeni, netdev, linux-kernel

> 
> On Wed, Jul 16, 2025 at 08:15:23AM +0800, Zqiang wrote:
> 
> > 
> > This commit make init_status() return -ENOMEM, if invoke
> > 
> >  kmalloc() return failed.
> > 
> >  
> > 
> >  Signed-off-by: Zqiang <qiang.zhang@linux.dev>
> > 
> 
> 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?

> 
> 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


>

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

* Re: [PATCH] net: usb: Remove duplicate assignments for net->pcpu_stat_type
  2025-07-16 22:11   ` Jakub Kicinski
@ 2025-07-17  0:08     ` qiang.zhang
  0 siblings, 0 replies; 8+ messages in thread
From: qiang.zhang @ 2025-07-17  0:08 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: oneukum, andrew+netdev, davem, pabeni, netdev, linux-kernel

> 
> On Wed, 16 Jul 2025 08:15:24 +0800 Zqiang wrote:
> 
> > 
> > Signed-off-by: Zqiang <qiang.zhang@linux.dev>
> > 
> 
> 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

> 
> -- 
> 
> pw-bot: cr
>

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

* Re: [PATCH] net: usb: Remove duplicate assignments for net->pcpu_stat_type
  2025-07-16  0:15 ` [PATCH] net: usb: Remove duplicate assignments for net->pcpu_stat_type Zqiang
  2025-07-16  9:19   ` Simon Horman
  2025-07-16 22:11   ` Jakub Kicinski
@ 2025-07-21  9:50   ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 8+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-07-21  9:50 UTC (permalink / raw)
  To: Zqiang; +Cc: oneukum, kuba, andrew+netdev, davem, pabeni, netdev, linux-kernel

Hello:

This patch was applied to netdev/net-next.git (main)
by David S. Miller <davem@davemloft.net>:

On Wed, 16 Jul 2025 08:15:24 +0800 you wrote:
> This commit remove duplicate assignments for net->pcpu_stat_type
> in usbnet_probe().
> 
> Signed-off-by: Zqiang <qiang.zhang@linux.dev>
> ---
>  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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2025-07-21  9:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-16  0:15 [PATCH] net: usb: Make init_satus() return -ENOMEM if alloc failed Zqiang
2025-07-16  0:15 ` [PATCH] net: usb: Remove duplicate assignments for net->pcpu_stat_type Zqiang
2025-07-16  9:19   ` Simon Horman
2025-07-16 22:11   ` Jakub Kicinski
2025-07-17  0:08     ` qiang.zhang
2025-07-21  9:50   ` patchwork-bot+netdevbpf
2025-07-16  9:18 ` [PATCH] net: usb: Make init_satus() return -ENOMEM if alloc failed Simon Horman
2025-07-17  0:04   ` qiang.zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).