net: hso: bail out on interrupt URB allocation failure
Subsystems (5)
PATCH 1/1 net: hso: bail out on interrupt URB allocation failure
Commit 31db0dbd7244 ("net: hso: check for allocation failure in hso_create_bulk_serial_device()") recently started returning an error when the driver fails to allocate resources for the interrupt endpoint and tiocmget functionality.
For consistency let's bail out from probe also if the URB allocation fails.
--- drivers/net/usb/hso.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/net/usb/hso.c +7 -7
@@ -2635,14 +2635,14 @@ static struct hso_device *hso_create_bulk_serial_device( } tiocmget->urb =usb_alloc_urb (0 ,GFP_KERNEL ); -if (tiocmget->urb) { -mutex_init (&tiocmget->mutex); -init_waitqueue_head (&tiocmget->waitq); - }else -hso_free_tiomget (serial); - } -else +if (!tiocmget->urb) + goto exit; + +mutex_init (&tiocmget->mutex); +init_waitqueue_head (&tiocmget->waitq); + }else { num_urbs =1 ; + }if (hso_serial_common_create (serial, num_urbs,BULK_URB_RX_SIZE ,BULK_URB_TX_SIZE ))
Signature · 1 line
2.26.3
Quoted 18 lines · Johan Hovold
Commit
31db0dbd7244("net: hso: check for allocation failure inhso_create_bulk_serial_device()") recently started returning an error when the driver fails to allocate resources for the interrupt endpoint and tiocmget functionality.For consistency let's bail out from probe also if the URB allocation fails.
Signed-off-by Johan Hovold <[email protected]>--- drivers/net/usb/hso.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)drivers/net/usb/hso.c +0
-0
drivers/net/usb/hso.c static struct hso_device *hso_create_bulk_serial_device( · line 2642
Quoted 8 lines
drivers/net/usb/hso.c +0
-5@@ -2635,14 +2635,14 @@ static struct hso_device *hso_create_bulk_serial_device( } tiocmget->urb =usb_alloc_urb (0 ,GFP_KERNEL ); -if (tiocmget->urb) { -mutex_init (&tiocmget->mutex); -init_waitqueue_head (&tiocmget->waitq); - }else -hso_free_tiomget (serial);
Thanks! The original code works, but it's so suspicious looking because you would think hso_free_tiomget() lead to a use after free later.
regards,
dan carpenter
This patch was applied to netdev/net.git (refs/heads/master):
Hello:
This patch was applied to netdev/net.git (refs/heads/master):
Quoted 9 lines · On Wed, 19 May 2021 14:47:17 +0200 you wrote:
Commit
31db0dbd7244("net: hso: check for allocation failure inhso_create_bulk_serial_device()") recently started returning an error when the driver fails to allocate resources for the interrupt endpoint and tiocmget functionality.For consistency let's bail out from probe also if the URB allocation fails.
[...]
Here is the summary with links:
- [net] net: hso: bail out on interrupt URB allocation failure
https://git.kernel.org/netdev/net/c/4d52ebc7ace4
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html