can: usb: etas_es58x: correctly anchor the urb in the read bulk callback
Subsystems (2)
PATCH 1/1 can: usb: etas_es58x: correctly anchor the urb in the read bulk callback
When submitting an urb, that is using the anchor pattern, it needs to be anchored before submitting it otherwise it could be leaked if usb_kill_anchored_urbs() is called. This logic is correctly done elsewhere in the driver, except in the read bulk callback so do that here also.
--- drivers/net/can/usb/etas_es58x/es58x_core.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/can/usb/etas_es58x/es58x_core.c +7 -1
@@ -1461,12 +1461,18 @@ static void es58x_read_bulk_callback(struct urb *urb) } resubmit_urb: +usb_anchor_urb (urb, &es58x_dev->rx_urbs); ret =usb_submit_urb (urb,GFP_ATOMIC ); +if (!ret) +return ; + +usb_unanchor_urb (urb); +if (ret == -ENODEV ) {for (i =0 ; i < es58x_dev->num_can_ch; i++)if (es58x_dev->netdev[i])netif_device_detach (es58x_dev->netdev[i]); - }else if (ret) + }else dev_err_ratelimited (dev,"Failed resubmitting read bulk urb: %pe\n" ,ERR_PTR (ret));
Signature · 1 line
2.53.0
Quoted 5 lines · Greg Kroah-Hartman
When submitting an urb, that is using the anchor pattern, it needs to be anchored before submitting it otherwise it could be leaked if
usb_kill_anchored_urbs()is called. This logic is correctly done elsewhere in the driver, except in the read bulk callback so do that here also.
I can explain why this bug went through the cracks. When I wrote this driver, I was actually wondering whether I had to manually re-anchor the urbs. I checked the documentation of usb_submit_urb() and usb_fill_bulk_urb() but there was no mention that the urb will be unachored by the framework before calling urb->complete(). And so, I assumed that it would stay anchored. And I ended up just anchoring them once at creation and then reuse them without paying attention to the anchor any more.
Now that I see your patch, I had a look at the code source and can see that indeed __usb_hcd_giveback_urb() will unanchor the urbs.
Anyway, thanks for the fix!
Quoted 5 lines
Cc Vincent Mailhol <[email protected]>Cc Marc Kleine-Budde <[email protected]>Cc stable <[email protected]>Assisted-by gkh_clanker_2000Signed-off-by Greg Kroah-Hartman <[email protected]>
Yours sincerely,
Vincent Mailhol
Quoted 9 lines · Greg Kroah-Hartman
When submitting an urb, that is using the anchor pattern, it needs to be anchored before submitting it otherwise it could be leaked if
usb_kill_anchored_urbs()is called. This logic is correctly done elsewhere in the driver, except in the read bulk callback so do that here also.Cc Vincent Mailhol <[email protected]>Cc Marc Kleine-Budde <[email protected]>Cc stable <[email protected]>
FYI: checkpatch suggests:
Invalid email format for stable: 'stable <[email protected]>', prefer '[email protected]'
Quoted 2 lines
Assisted-by gkh_clanker_2000Signed-off-by Greg Kroah-Hartman <[email protected]>
Applied to linux-can, with preferred stable format.
Thanks,
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung Nürnberg | Phone: +49-5121-206917-129 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
Quoted 7 lines · Marc Kleine-Budde
Quoted 6 lines · Greg Kroah-Hartman
When submitting an urb, that is using the anchor pattern, it needs to be anchored before submitting it otherwise it could be leaked if
usb_kill_anchored_urbs()is called. This logic is correctly done elsewhere in the driver, except in the read bulk callback so do that here also.
Quoted 6 lines
Quoted 3 lines
Cc Vincent Mailhol <[email protected]>Cc Marc Kleine-Budde <[email protected]>Cc stable <[email protected]>FYI: checkpatch suggests:
Invalid email format for stable: 'stable <[email protected]>', prefer '[email protected]'
Checkpatch is wrong here, either is just fine.
thanks,
greg k-h
Marc Kleine-Budde
maintainercheckpatch: format of [email protected] address (was: Re: [PATCH] can: usb: etas_es58x: correctly anchor the urb in the read bulk callback)
Quoted 8 lines · Greg Kroah-Hartman
Quoted 7 lines · Marc Kleine-Budde
Quoted 6 lines · Greg Kroah-Hartman
When submitting an urb, that is using the anchor pattern, it needs to be anchored before submitting it otherwise it could be leaked if
usb_kill_anchored_urbs()is called. This logic is correctly done elsewhere in the driver, except in the read bulk callback so do that here also.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Cc Vincent Mailhol <[email protected]>Cc Marc Kleine-Budde <[email protected]>Cc stable <[email protected]>FYI: checkpatch suggests:
Invalid email format for stable: 'stable <[email protected]>', prefer '[email protected]'Checkpatch is wrong here, either is just fine.
That check was introduced by Dwaipayan Ray (Cc'ed) in commit fccaebf00e60 ("checkpatch: improve email parsing"), a.k.a. v5.11-rc1~133^2~46.
regards,
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung Nürnberg | Phone: +49-5121-206917-129 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
Re: checkpatch: format of [email protected] address (was: Re: [PATCH] can: usb: etas_es58x: correctly anchor the urb in the read bulk callback)
Quoted 13 lines · Marc Kleine-Budde
Quoted 12 lines · Greg Kroah-Hartman
Quoted 11 lines · Marc Kleine-Budde
Quoted 9 lines · Greg Kroah-Hartman
When submitting an urb, that is using the anchor pattern, it needs to be anchored before submitting it otherwise it could be leaked if
usb_kill_anchored_urbs()is called. This logic is correctly done elsewhere in the driver, except in the read bulk callback so do that here also.Cc Vincent Mailhol <[email protected]>Cc Marc Kleine-Budde <[email protected]>Cc stable <[email protected]>
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
FYI: checkpatch suggests:
Invalid email format for stable: 'stable <[email protected]>', prefer '[email protected]'Checkpatch is wrong here, either is just fine.
That check was introduced by Dwaipayan Ray (Cc'ed) in commit
fccaebf00e60("checkpatch: improve email parsing"), a.k.a. v5.11-rc1~133^2~46.
That's some regex hell that I don't want to attempt to fix up, but really, what I have here is just fine, and "should" be ok by checkpatch as well.
thanks,
greg k-h