All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] net: hso: bail out on interrupt URB allocation failure
@ 2021-05-19 12:47 Johan Hovold
  2021-05-19 13:23 ` Dan Carpenter
  2021-05-19 20:20 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Johan Hovold @ 2021-05-19 12:47 UTC (permalink / raw)
  To: David S. Miller
  Cc: Jakub Kicinski, Dan Carpenter, linux-usb, netdev, linux-kernel,
	Johan Hovold

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.

Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/net/usb/hso.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index 260f850d69eb..b48b2a25210c 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -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))
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net] net: hso: bail out on interrupt URB allocation failure
  2021-05-19 12:47 [PATCH net] net: hso: bail out on interrupt URB allocation failure Johan Hovold
@ 2021-05-19 13:23 ` Dan Carpenter
  2021-05-19 20:20 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2021-05-19 13:23 UTC (permalink / raw)
  To: Johan Hovold
  Cc: David S. Miller, Jakub Kicinski, linux-usb, netdev, linux-kernel

On Wed, May 19, 2021 at 02:47:17PM +0200, Johan Hovold wrote:
> 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.
> 
> Signed-off-by: Johan Hovold <johan@kernel.org>
> ---
>  drivers/net/usb/hso.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
> index 260f850d69eb..b48b2a25210c 100644
> --- a/drivers/net/usb/hso.c
> +++ b/drivers/net/usb/hso.c
> @@ -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.

Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] net: hso: bail out on interrupt URB allocation failure
  2021-05-19 12:47 [PATCH net] net: hso: bail out on interrupt URB allocation failure Johan Hovold
  2021-05-19 13:23 ` Dan Carpenter
@ 2021-05-19 20:20 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-05-19 20:20 UTC (permalink / raw)
  To: Johan Hovold; +Cc: davem, kuba, dan.carpenter, linux-usb, netdev, linux-kernel

Hello:

This patch was applied to netdev/net.git (refs/heads/master):

On Wed, 19 May 2021 14:47:17 +0200 you wrote:
> 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.
> 
> [...]

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



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-05-19 20:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-19 12:47 [PATCH net] net: hso: bail out on interrupt URB allocation failure Johan Hovold
2021-05-19 13:23 ` Dan Carpenter
2021-05-19 20:20 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.