* [PATCH v2] net: usb: net1080: add error handling to nc_vendor_write()
@ 2026-07-28 11:42 Ashwin Gundarapu
2026-07-28 21:05 ` Andrew Lunn
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Ashwin Gundarapu @ 2026-07-28 11:42 UTC (permalink / raw)
To: netdev; +Cc: linux-usb, linux-kernel, andrew
From 8c6ffd0b1a5ac33fb6a81cfd4d7d2c54462233bc Mon Sep 17 00:00:00 2001
From: Ashwin Gundarapu <linuxuser509@zohomail.in>
Date: Mon, 27 Jul 2026 19:34:16 +0530
Subject: [PATCH] net: usb: net1080: add error handling to nc_vendor_write()
The nc_vendor_write() function currently ignores the return value of
usbnet_write_cmd(). This can lead to silent failures when USB
communication fails.
Change nc_vendor_write() and nc_register_write() to return int
instead of void, and propagate the error from usbnet_write_cmd()
back to the caller.
Also fix the callers in net1080_reset() to check the return value
and handle errors appropriately. Remove an unused #if 0 block while
at it.
Signed-off-by: Ashwin Gundarapu <linuxuser509@zohomail.in>
---
drivers/net/usb/net1080.c | 55 +++++++++++++--------------------------
1 file changed, 18 insertions(+), 37 deletions(-)
diff --git a/drivers/net/usb/net1080.c b/drivers/net/usb/net1080.c
index 19f6e1222d93..87848f6e8e01 100644
--- a/drivers/net/usb/net1080.c
+++ b/drivers/net/usb/net1080.c
@@ -113,49 +113,22 @@ nc_register_read(struct usbnet *dev, u8 regnum, u16 *retval_ptr)
return nc_vendor_read(dev, REQUEST_REGISTER, regnum, retval_ptr);
}
-static void
+static int
nc_vendor_write(struct usbnet *dev, u8 req, u8 regnum, u16 value)
{
- usbnet_write_cmd(dev, req,
- USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
- value, regnum, NULL, 0);
+ return usbnet_write_cmd(dev, req,
+ USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
+ value, regnum, NULL, 0);
}
-static inline void
+static inline int
nc_register_write(struct usbnet *dev, u8 regnum, u16 value)
{
- nc_vendor_write(dev, REQUEST_REGISTER, regnum, value);
+ return nc_vendor_write(dev, REQUEST_REGISTER, regnum, value);
}
-#if 0
-static void nc_dump_registers(struct usbnet *dev)
-{
- u8 reg;
- u16 *vp = kmalloc(sizeof (u16));
-
- if (!vp)
- return;
- netdev_dbg(dev->net, "registers:\n");
- for (reg = 0; reg < 0x20; reg++) {
- int retval;
-
- // reading some registers is trouble
- if (reg >= 0x08 && reg <= 0xf)
- continue;
- if (reg >= 0x12 && reg <= 0x1e)
- continue;
-
- retval = nc_register_read(dev, reg, vp);
- if (retval < 0)
- netdev_dbg(dev->net, "reg [0x%x] ==> error %d\n",
- reg, retval);
- else
- netdev_dbg(dev->net, "reg [0x%x] = 0x%x\n", reg, *vp);
- }
- kfree(vp);
-}
#endif
@@ -279,8 +252,12 @@ static int net1080_reset(struct usbnet *dev)
usbctl = vp;
nc_dump_usbctl(dev, usbctl);
- nc_register_write(dev, REG_USBCTL,
- USBCTL_FLUSH_THIS | USBCTL_FLUSH_OTHER);
+ retval = nc_register_write(dev, REG_USBCTL,
+ USBCTL_FLUSH_THIS | USBCTL_FLUSH_OTHER);
+ if (retval < 0) {
+ netdev_dbg(dev->net, "can't write USBCTL: %d\n", retval);
+ goto done;
+ }
if ((retval = nc_register_read(dev, REG_TTL, &vp)) < 0) {
netdev_dbg(dev->net, "can't read TTL, %d\n", retval);
@@ -288,8 +265,12 @@ static int net1080_reset(struct usbnet *dev)
}
ttl = vp;
- nc_register_write(dev, REG_TTL,
- MK_TTL(NC_READ_TTL_MS, TTL_OTHER(ttl)) );
+ retval = nc_register_write(dev, REG_TTL,
+ MK_TTL(NC_READ_TTL_MS, TTL_OTHER(ttl)));
+ if (retval < 0) {
+ netdev_dbg(dev->net, "can't write TTL: %d\n", retval);
+ goto done;
+ }
netdev_dbg(dev->net, "assigned TTL, %d ms\n", NC_READ_TTL_MS);
netif_info(dev, link, dev->net, "port %c, peer %sconnected\n",
--
2.53.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH v2] net: usb: net1080: add error handling to nc_vendor_write()
2026-07-28 11:42 [PATCH v2] net: usb: net1080: add error handling to nc_vendor_write() Ashwin Gundarapu
@ 2026-07-28 21:05 ` Andrew Lunn
2026-07-31 13:25 ` kernel test robot
2026-07-31 13:58 ` kernel test robot
2 siblings, 0 replies; 4+ messages in thread
From: Andrew Lunn @ 2026-07-28 21:05 UTC (permalink / raw)
To: Ashwin Gundarapu; +Cc: netdev, linux-usb, linux-kernel
On Tue, Jul 28, 2026 at 05:12:50PM +0530, Ashwin Gundarapu wrote:
> >From 8c6ffd0b1a5ac33fb6a81cfd4d7d2c54462233bc Mon Sep 17 00:00:00 2001
> From: Ashwin Gundarapu <linuxuser509@zohomail.in>
> Date: Mon, 27 Jul 2026 19:34:16 +0530
> Subject: [PATCH] net: usb: net1080: add error handling to nc_vendor_write()
>
> The nc_vendor_write() function currently ignores the return value of
> usbnet_write_cmd(). This can lead to silent failures when USB
> communication fails.
>
> Change nc_vendor_write() and nc_register_write() to return int
> instead of void, and propagate the error from usbnet_write_cmd()
> back to the caller.
>
> Also fix the callers in net1080_reset() to check the return value
> and handle errors appropriately. Remove an unused #if 0 block while
> at it.
This patch is doing multiple things. Please turn it into two patches
in a series.
Andrew
---
pw-bot: cr
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v2] net: usb: net1080: add error handling to nc_vendor_write()
2026-07-28 11:42 [PATCH v2] net: usb: net1080: add error handling to nc_vendor_write() Ashwin Gundarapu
2026-07-28 21:05 ` Andrew Lunn
@ 2026-07-31 13:25 ` kernel test robot
2026-07-31 13:58 ` kernel test robot
2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2026-07-31 13:25 UTC (permalink / raw)
To: Ashwin Gundarapu, netdev; +Cc: oe-kbuild-all, linux-usb, linux-kernel, andrew
Hi Ashwin,
kernel test robot noticed the following build errors:
[auto build test ERROR on net/main]
[also build test ERROR on net-next/main linus/master horms-ipvs/master v7.2-rc5 next-20260730]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Ashwin-Gundarapu/net-usb-net1080-add-error-handling-to-nc_vendor_write/20260731-180509
base: net/main
patch link: https://lore.kernel.org/r/19fa888e049.512e8c5e24030.7986824281565553606%40zohomail.in
patch subject: [PATCH v2] net: usb: net1080: add error handling to nc_vendor_write()
config: alpha-allmodconfig (https://download.01.org/0day-ci/archive/20260731/202607312111.RaYDdcfw-lkp@intel.com/config)
compiler: alpha-linux-gcc (GCC) 16.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260731/202607312111.RaYDdcfw-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202607312111.RaYDdcfw-lkp@intel.com/
All errors (new ones prefixed by >>):
>> drivers/net/usb/net1080.c:132:2: error: '#endif' without '#if'
132 | #endif
| ^~~~~
vim +132 drivers/net/usb/net1080.c
904813cd8a0b33 drivers/usb/net/net1080.c David Brownell 2005-08-31 129
904813cd8a0b33 drivers/usb/net/net1080.c David Brownell 2005-08-31 130
904813cd8a0b33 drivers/usb/net/net1080.c David Brownell 2005-08-31 131
904813cd8a0b33 drivers/usb/net/net1080.c David Brownell 2005-08-31 @132 #endif
904813cd8a0b33 drivers/usb/net/net1080.c David Brownell 2005-08-31 133
904813cd8a0b33 drivers/usb/net/net1080.c David Brownell 2005-08-31 134
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v2] net: usb: net1080: add error handling to nc_vendor_write()
2026-07-28 11:42 [PATCH v2] net: usb: net1080: add error handling to nc_vendor_write() Ashwin Gundarapu
2026-07-28 21:05 ` Andrew Lunn
2026-07-31 13:25 ` kernel test robot
@ 2026-07-31 13:58 ` kernel test robot
2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2026-07-31 13:58 UTC (permalink / raw)
To: Ashwin Gundarapu, netdev
Cc: llvm, oe-kbuild-all, linux-usb, linux-kernel, andrew
Hi Ashwin,
kernel test robot noticed the following build errors:
[auto build test ERROR on net/main]
[also build test ERROR on net-next/main linus/master v7.2-rc5 next-20260730]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Ashwin-Gundarapu/net-usb-net1080-add-error-handling-to-nc_vendor_write/20260731-180509
base: net/main
patch link: https://lore.kernel.org/r/19fa888e049.512e8c5e24030.7986824281565553606%40zohomail.in
patch subject: [PATCH v2] net: usb: net1080: add error handling to nc_vendor_write()
config: x86_64-kexec (https://download.01.org/0day-ci/archive/20260731/202607311511.xIUupBfm-lkp@intel.com/config)
compiler: clang version 22.1.8 (https://github.com/llvm/llvm-project ca7933e47d3a3451d81e72ac174dcb5aa28b59d1)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260731/202607311511.xIUupBfm-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202607311511.xIUupBfm-lkp@intel.com/
All errors (new ones prefixed by >>):
>> drivers/net/usb/net1080.c:132:2: error: #endif without #if
132 | #endif
| ^
1 error generated.
vim +132 drivers/net/usb/net1080.c
904813cd8a0b334 drivers/usb/net/net1080.c David Brownell 2005-08-31 129
904813cd8a0b334 drivers/usb/net/net1080.c David Brownell 2005-08-31 130
904813cd8a0b334 drivers/usb/net/net1080.c David Brownell 2005-08-31 131
904813cd8a0b334 drivers/usb/net/net1080.c David Brownell 2005-08-31 @132 #endif
904813cd8a0b334 drivers/usb/net/net1080.c David Brownell 2005-08-31 133
904813cd8a0b334 drivers/usb/net/net1080.c David Brownell 2005-08-31 134
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-07-31 13:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-28 11:42 [PATCH v2] net: usb: net1080: add error handling to nc_vendor_write() Ashwin Gundarapu
2026-07-28 21:05 ` Andrew Lunn
2026-07-31 13:25 ` kernel test robot
2026-07-31 13:58 ` kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox