diff mbox series

[1/1] hush: avoid NULL check before free()

Message ID 20200428195610.16002-1-xypron.glpk@gmx.de
State Accepted
Commit f4070e6f6c680034d67f13b878f0da55b3b51f92
Headers show
Series [1/1] hush: avoid NULL check before free() | expand

Commit Message

Heinrich Schuchardt April 28, 2020, 7:56 p.m. UTC
free() checks if its argument is NULL. Don't duplicate this in the calling
code.

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

--
2.26.2

Comments

Simon Glass April 28, 2020, 10:40 p.m. UTC | #1
On Tue, 28 Apr 2020 at 13:56, Heinrich Schuchardt <xypron.glpk at gmx.de> wrote:
>
> free() checks if its argument is NULL. Don't duplicate this in the calling
> code.
>
> Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
> ---
>  common/cli_hush.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>

Reviewed-by: Simon Glass <sjg at chromium.org>
Tom Rini May 1, 2020, 9:57 p.m. UTC | #2
On Tue, Apr 28, 2020 at 09:56:10PM +0200, Heinrich Schuchardt wrote:

> free() checks if its argument is NULL. Don't duplicate this in the calling
> code.
> 
> Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
> Reviewed-by: Simon Glass <sjg at chromium.org>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/common/cli_hush.c b/common/cli_hush.c
index cf1e273485..a62af07cc5 100644
--- a/common/cli_hush.c
+++ b/common/cli_hush.c
@@ -1849,8 +1849,7 @@  static int run_list_real(struct pipe *pi)
 				continue;
 			} else {
 				/* insert new value from list for variable */
-				if (pi->progs->argv[0])
-					free(pi->progs->argv[0]);
+				free(pi->progs->argv[0]);
 				pi->progs->argv[0] = *list++;
 #ifndef __U_BOOT__
 				pi->progs->glob_result.gl_pathv[0] =