diff mbox series

usb: avoid NULL check before free

Message ID 20200419100228.27804-1-xypron.glpk@gmx.de
State Accepted
Commit cff0144e4cd0825dda0ae46aa739f0681839cc3a
Headers show
Series usb: avoid NULL check before free | expand

Commit Message

Heinrich Schuchardt April 19, 2020, 10:02 a.m. UTC
The free() function checks if the argument is NULL.
Do not duplicate this check.

Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
---
 drivers/usb/host/ehci-hcd.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

--
2.25.1

Comments

Marek Vasut April 20, 2020, 1:43 a.m. UTC | #1
On 4/19/20 12:02 PM, Heinrich Schuchardt wrote:
> The free() function checks if the argument is NULL.
> Do not duplicate this check.
> 
> Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
> ---
>  drivers/usb/host/ehci-hcd.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
> index 1edb344d0f..a2a85db1e7 100644
> --- a/drivers/usb/host/ehci-hcd.c
> +++ b/drivers/usb/host/ehci-hcd.c
> @@ -1413,13 +1413,10 @@ static struct int_queue *_ehci_create_int_queue(struct usb_device *dev,
>  	debug("Exit create_int_queue\n");
>  	return result;
>  fail3:
> -	if (result->tds)
> -		free(result->tds);
> +	free(result->tds);
>  fail2:
> -	if (result->first)
> -		free(result->first);
> -	if (result)
> -		free(result);
> +	free(result->first);
> +	free(result);
>  fail1:
>  	return NULL;
>  }
> --
> 2.25.1

Applied, thanks
diff mbox series

Patch

diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 1edb344d0f..a2a85db1e7 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -1413,13 +1413,10 @@  static struct int_queue *_ehci_create_int_queue(struct usb_device *dev,
 	debug("Exit create_int_queue\n");
 	return result;
 fail3:
-	if (result->tds)
-		free(result->tds);
+	free(result->tds);
 fail2:
-	if (result->first)
-		free(result->first);
-	if (result)
-		free(result);
+	free(result->first);
+	free(result);
 fail1:
 	return NULL;
 }