diff mbox series

usb: ether: avoid NULL check before free()

Message ID 20200419101112.36368-1-xypron.glpk@gmx.de
State Accepted
Commit 3c425fc0ef4de31d350695c74db7a3d6be0379b6
Headers show
Series usb: ether: avoid NULL check before free() | expand

Commit Message

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

Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
---
 drivers/usb/gadget/ether.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--
2.25.1

Comments

Marek Vasut April 20, 2020, 1:43 a.m. UTC | #1
On 4/19/20 12:11 PM, Heinrich Schuchardt wrote:
> free() checks if its argument is NULL. Do not duplicate this check.
> 
> Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
> ---
>  drivers/usb/gadget/ether.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
> index a118283984..8533abfd93 100644
> --- a/drivers/usb/gadget/ether.c
> +++ b/drivers/usb/gadget/ether.c
> @@ -2472,8 +2472,7 @@ static int _usb_eth_send(struct ether_priv *priv, void *packet, int length)
>  		}
>  		usb_gadget_handle_interrupts(0);
>  	}
> -	if (rndis_pkt)
> -		free(rndis_pkt);
> +	free(rndis_pkt);
> 
>  	return 0;
>  drop:
> --
> 2.25.1

Applied, thanks.
diff mbox series

Patch

diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index a118283984..8533abfd93 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -2472,8 +2472,7 @@  static int _usb_eth_send(struct ether_priv *priv, void *packet, int length)
 		}
 		usb_gadget_handle_interrupts(0);
 	}
-	if (rndis_pkt)
-		free(rndis_pkt);
+	free(rndis_pkt);

 	return 0;
 drop: