diff mbox

[REBASED,1/2] usbip: usbip_host: delete device from busid_table after rebind

Message ID 9cfffc546fc9774a9e38e81b0f396866a9d8d11f.1525115738.git.shuah@kernel.org (mailing list archive)
State New, archived
Headers show

Commit Message

Shuah April 30, 2018, 10:17 p.m. UTC
Device is left in the busid_table after unbind and rebind. Rebind
initiates usb bus scan and the original driver claims the device.
After rescan the device should be deleted from the busid_table as
it no longer belongs to usbip_host.

Fix it to delete the device after device_attach() succeeds.

Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>
---
 drivers/usb/usbip/stub_main.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Greg Kroah-Hartman April 30, 2018, 10:48 p.m. UTC | #1
On Mon, Apr 30, 2018 at 04:17:19PM -0600, Shuah Khan (Samsung OSG) wrote:
> Device is left in the busid_table after unbind and rebind. Rebind
> initiates usb bus scan and the original driver claims the device.
> After rescan the device should be deleted from the busid_table as
> it no longer belongs to usbip_host.
> 
> Fix it to delete the device after device_attach() succeeds.
> 
> Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>
> ---
>  drivers/usb/usbip/stub_main.c | 6 ++++++
>  1 file changed, 6 insertions(+)

Why are these REBASED?  I can't remember the first version of these
patches, what are these for?

confused,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Shuah April 30, 2018, 11:12 p.m. UTC | #2
On 04/30/2018 04:48 PM, Greg KH wrote:
> On Mon, Apr 30, 2018 at 04:17:19PM -0600, Shuah Khan (Samsung OSG) wrote:
>> Device is left in the busid_table after unbind and rebind. Rebind
>> initiates usb bus scan and the original driver claims the device.
>> After rescan the device should be deleted from the busid_table as
>> it no longer belongs to usbip_host.
>>
>> Fix it to delete the device after device_attach() succeeds.
>>
>> Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>
>> ---
>>  drivers/usb/usbip/stub_main.c | 6 ++++++
>>  1 file changed, 6 insertions(+)
> 
> Why are these REBASED?  I can't remember the first version of these
> patches, what are these for?
> 
> confused,
> 
> greg k-h
> 
> 

Here is the original patches

https://patchwork.kernel.org/patch/10337657/
https://patchwork.kernel.org/patch/10337661/

I sent a 3 patch series and the last two didn't apply to usb-next. You asked me to
rebase them. I realized the reason they didn't apply is because these two depend on
the fixes that went into 4.17-rc3 and now with usb-next at 4.17-rc3, they apply.

I ended up generating patches on usb-next latest and resend the rebased patches.

Hope this makes sense.

thanks,
-- Shuah


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/usb/usbip/stub_main.c b/drivers/usb/usbip/stub_main.c
index d41d0cdeec0f..fb46bd62d538 100644
--- a/drivers/usb/usbip/stub_main.c
+++ b/drivers/usb/usbip/stub_main.c
@@ -186,6 +186,9 @@  static ssize_t rebind_store(struct device_driver *dev, const char *buf,
 	if (!bid)
 		return -ENODEV;
 
+	/* mark the device for deletion so probe ignores it during rescan */
+	bid->status = STUB_BUSID_OTHER;
+
 	/* device_attach() callers should hold parent lock for USB */
 	if (bid->udev->dev.parent)
 		device_lock(bid->udev->dev.parent);
@@ -197,6 +200,9 @@  static ssize_t rebind_store(struct device_driver *dev, const char *buf,
 		return ret;
 	}
 
+	/* delete device from busid_table */
+	del_match_busid((char *) buf);
+
 	return count;
 }