diff mbox series

net: usb: qmi_wwan: Add error handling for usbnet_get_ethernet_addr

Message ID 20250120170026.1880-1-vulab@iscas.ac.cn (mailing list archive)
State Rejected
Delegated to: Netdev Maintainers
Headers show
Series net: usb: qmi_wwan: Add error handling for usbnet_get_ethernet_addr | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers fail 2 blamed authors not CCed: gregkh@linuxfoundation.org bjorn@mork.no; 5 maintainers not CCed: andrew+netdev@lunn.ch bjorn@mork.no edumazet@google.com gregkh@linuxfoundation.org pabeni@redhat.com
netdev/build_clang success Errors and warnings before: 1 this patch: 1
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 10 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest fail net-next-2025-01-20--18-02 (tests: 887)

Commit Message

Wentao Liang Jan. 20, 2025, 5 p.m. UTC
In qmi_wwan_bind(), usbnet_get_ethernet_addr() is called
without error handling, risking unnoticed failures and
inconsistent behavior compared to other parts of the code.

Fix this issue by adding an error handling for the
usbnet_get_ethernet_addr(), improving code robustness.

Fixes: 423ce8caab7e ("net: usb: qmi_wwan: New driver for Huawei QMI based WWAN devices")
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/net/usb/qmi_wwan.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Breno Leitao Jan. 20, 2025, 5:34 p.m. UTC | #1
On Tue, Jan 21, 2025 at 01:00:26AM +0800, Wentao Liang wrote:
> In qmi_wwan_bind(), usbnet_get_ethernet_addr() is called
> without error handling, risking unnoticed failures and
> inconsistent behavior compared to other parts of the code.
> 
> Fix this issue by adding an error handling for the
> usbnet_get_ethernet_addr(), improving code robustness.
> 
> Fixes: 423ce8caab7e ("net: usb: qmi_wwan: New driver for Huawei QMI based WWAN devices")
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>

Reviewed-by: Breno Leitao <leitao@debian.org>
Bjørn Mork Jan. 20, 2025, 6:06 p.m. UTC | #2
Wentao Liang <vulab@iscas.ac.cn> writes:

> In qmi_wwan_bind(), usbnet_get_ethernet_addr() is called
> without error handling, risking unnoticed failures and
> inconsistent behavior compared to other parts of the code.
>
> Fix this issue by adding an error handling for the
> usbnet_get_ethernet_addr(), improving code robustness.
>
> Fixes: 423ce8caab7e ("net: usb: qmi_wwan: New driver for Huawei QMI based WWAN devices")
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
>  drivers/net/usb/qmi_wwan.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
> index e9208a8d2bfa..7aa576bfe76b 100644
> --- a/drivers/net/usb/qmi_wwan.c
> +++ b/drivers/net/usb/qmi_wwan.c
> @@ -779,7 +779,9 @@ static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf)
>  	/* errors aren't fatal - we can live with the dynamic address */
>  	if (cdc_ether && cdc_ether->wMaxSegmentSize) {
>  		dev->hard_mtu = le16_to_cpu(cdc_ether->wMaxSegmentSize);
> -		usbnet_get_ethernet_addr(dev, cdc_ether->iMACAddress);
> +		status = usbnet_get_ethernet_addr(dev, cdc_ether->iMACAddress);
> +		if (status < 0)
> +			goto err;
>  	}
>  
>  	/* claim data interface and set it up */



Did you read the comment?

This intentinonally ignores any errors.  I don't know how to make it
clear anough for these AI bots to understand.  Any advice there?


NAK

(and why weren't I CCed?  Noticed this by chance only...)


Bjørn
diff mbox series

Patch

diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
index e9208a8d2bfa..7aa576bfe76b 100644
--- a/drivers/net/usb/qmi_wwan.c
+++ b/drivers/net/usb/qmi_wwan.c
@@ -779,7 +779,9 @@  static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf)
 	/* errors aren't fatal - we can live with the dynamic address */
 	if (cdc_ether && cdc_ether->wMaxSegmentSize) {
 		dev->hard_mtu = le16_to_cpu(cdc_ether->wMaxSegmentSize);
-		usbnet_get_ethernet_addr(dev, cdc_ether->iMACAddress);
+		status = usbnet_get_ethernet_addr(dev, cdc_ether->iMACAddress);
+		if (status < 0)
+			goto err;
 	}
 
 	/* claim data interface and set it up */