Skip to contentSkip to conversation

usb: gadget: f_ecm: Fix ecm_opts->bound logic in bind path

PATCH In review Kuen-Han Tsai 2 participants 4 messages Sep 4, 2025 USB

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 usb: gadget: f_ecm: Fix ecm_opts->bound logic in bind path

The bound flag in ecm_opts is being set to true even if gether_register_netdev() failed.

Move the assignment of ecm_opts->bound to after the success check to ensure the flag only reflects the true state. The race condition on this flag is not a concern because the caller, configfs_composite_bind(), binds functions sequentially.

Fixes d65e6b6e884a ("usb: gadget: f_ecm: Always set current gadget in ecm_bind()")
---
 drivers/usb/gadget/function/f_ecm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/gadget/function/f_ecm.c +2 -1
index 027226325039..9f5ed6f32a62 100644
@@ -690,13 +690,14 @@ ecm_bind(struct usb_configuration *c, struct usb_function *f)
 
 	if (!ecm_opts->bound) {
 		status = gether_register_netdev(ecm_opts->net);
-		ecm_opts->bound = true;
 	}
 
 	mutex_unlock(&ecm_opts->lock);
 	if (status)
 		return status;
 
+	ecm_opts->bound = true;
+
 	ecm_string_defs[1].s = ecm->ethaddr;
 
 	us = usb_gstrings_attach(cdev, ecm_strings,
Signature · 1 line
2.51.0.338.gd7d06c2dae-goog
maintainer
#1 lore raw
Quoted 39 lines · Kuen-Han Tsai

The bound flag in ecm_opts is being set to true even if gether_register_netdev() failed.

Move the assignment of ecm_opts->bound to after the success check to ensure the flag only reflects the true state. The race condition on this flag is not a concern because the caller, configfs_composite_bind(), binds functions sequentially.

Fixes d65e6b6e884a ("usb: gadget: f_ecm: Always set current gadget in ecm_bind()")
---
 drivers/usb/gadget/function/f_ecm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/gadget/function/f_ecm.c +2 -1
index 027226325039..9f5ed6f32a62 100644
@@ -690,13 +690,14 @@ ecm_bind(struct usb_configuration *c, struct usb_function *f)
 
 	if (!ecm_opts->bound) {
 		status = gether_register_netdev(ecm_opts->net);
-		ecm_opts->bound = true;
 	}
 
 	mutex_unlock(&ecm_opts->lock);
 	if (status)
 		return status;
 
+	ecm_opts->bound = true;
+
 	ecm_string_defs[1].s = ecm->ethaddr;
 
 	us = usb_gstrings_attach(cdev, ecm_strings,
Signature · 1 line
2.51.0.338.gd7d06c2dae-goog

Hi,

This is the friendly semi-automated patch-bot of Greg Kroah-Hartman. You have sent him a patch that has triggered this response.

Right now, the development tree you have sent a patch for is "closed" due to the timing of the merge window. Don't worry, the patch(es) you have sent are not lost, and will be looked at after the merge window is over (after the -rc1 kernel is released by Linus).

So thank you for your patience and your patches will be reviewed at this later time, you do not have to do anything further, this is just a short note to let you know the patch status and so you don't worry they didn't make it through.

thanks,

greg k-h's patch email bot

maintainer
#2 lore raw
Quoted 52 lines · Greg KH
Quoted 39 lines · Kuen-Han Tsai

The bound flag in ecm_opts is being set to true even if gether_register_netdev() failed.

Move the assignment of ecm_opts->bound to after the success check to ensure the flag only reflects the true state. The race condition on this flag is not a concern because the caller, configfs_composite_bind(), binds functions sequentially.

Fixes d65e6b6e884a ("usb: gadget: f_ecm: Always set current gadget in ecm_bind()")
---
 drivers/usb/gadget/function/f_ecm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/gadget/function/f_ecm.c +2 -1
index 027226325039..9f5ed6f32a62 100644
@@ -690,13 +690,14 @@ ecm_bind(struct usb_configuration *c, struct usb_function *f)
 
 	if (!ecm_opts->bound) {
 		status = gether_register_netdev(ecm_opts->net);
-		ecm_opts->bound = true;
 	}
 
 	mutex_unlock(&ecm_opts->lock);
 	if (status)
 		return status;
 
+	ecm_opts->bound = true;
+
 	ecm_string_defs[1].s = ecm->ethaddr;
 
 	us = usb_gstrings_attach(cdev, ecm_strings,
Signature · 1 line
2.51.0.338.gd7d06c2dae-goog

Hi,

This is the friendly semi-automated patch-bot of Greg Kroah-Hartman. You have sent him a patch that has triggered this response.

Right now, the development tree you have sent a patch for is "closed" due to the timing of the merge window. Don't worry, the patch(es) you have sent are not lost, and will be looked at after the merge window is over (after the -rc1 kernel is released by Linus).

Quoted 8 lines

So thank you for your patience and your patches will be reviewed at this later time, you do not have to do anything further, this is just a short note to let you know the patch status and so you don't worry they didn't make it through.

thanks,

greg k-h's patch email bot

Oops, nope, wrong bot, forgot to turn this one off...

maintainer
#3 lore raw
In reply to Kuen-Han Tsai
Quoted 39 lines · Kuen-Han Tsai

The bound flag in ecm_opts is being set to true even if gether_register_netdev() failed.

Move the assignment of ecm_opts->bound to after the success check to ensure the flag only reflects the true state. The race condition on this flag is not a concern because the caller, configfs_composite_bind(), binds functions sequentially.

Fixes d65e6b6e884a ("usb: gadget: f_ecm: Always set current gadget in ecm_bind()")
---
 drivers/usb/gadget/function/f_ecm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/gadget/function/f_ecm.c +2 -1
index 027226325039..9f5ed6f32a62 100644
@@ -690,13 +690,14 @@ ecm_bind(struct usb_configuration *c, struct usb_function *f)
 
 	if (!ecm_opts->bound) {
 		status = gether_register_netdev(ecm_opts->net);
-		ecm_opts->bound = true;
 	}
 
 	mutex_unlock(&ecm_opts->lock);
 	if (status)
 		return status;
 
+	ecm_opts->bound = true;
+
 	ecm_string_defs[1].s = ecm->ethaddr;
 
 	us = usb_gstrings_attach(cdev, ecm_strings,
Signature · 1 line
2.51.0.338.gd7d06c2dae-goog

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him a patch that has triggered this response. He used to manually respond to these common problems, but in order to save his sanity (he kept writing the same thing over and over, yet to different people), I was created. Hopefully you will not take offence and will fix the problem in your patch and resubmit it so that it can be accepted into the Linux kernel tree.

You are receiving this message because of the following common error(s) as indicated below:

- This looks like a new version of a previously submitted patch, but you did not list below the --- line any changes from the previous version. Please read the section entitled "The canonical patch format" in the kernel file, Documentation/process/submitting-patches.rst for what needs to be done here to properly describe this.

If you wish to discuss this problem further, or you have questions about how to resolve this issue, please feel free to respond to this email and Greg will reply once he has dug out from the pending patches received from other developers.

thanks,

greg k-h's patch email bot