diff mbox series

[5/5] discover: pxe: Avoid dereferencing null pointer

Message ID 20180306040220.7519-6-joel@jms.id.au
State Accepted
Headers show
Series Misc fixes | expand

Commit Message

Joel Stanley March 6, 2018, 4:02 a.m. UTC
When result is null, we may end up in the error handling path where we
try to dereference null to cal cleanup_local. This adds a check for
result.

Found with scan-build.

Signed-off-by: Joel Stanley <joel@jms.id.au>
---
 discover/pxe-parser.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Cyril Bur March 6, 2018, 5:05 a.m. UTC | #1
On Tue, 2018-03-06 at 14:32 +1030, Joel Stanley wrote:
> When result is null, we may end up in the error handling path where we
> try to dereference null to cal cleanup_local. This adds a check for
> result.
                               ^l

> 
> Found with scan-build.
> 
> Signed-off-by: Joel Stanley <joel@jms.id.au>

Sam is such a nice guy I'm sure he'll fix it :)

Reviewed-by: Cyril Bur <cyrilbur@gmail.com>

> ---
>  discover/pxe-parser.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/discover/pxe-parser.c b/discover/pxe-parser.c
> index 5c80b1399973..d2ebaab0e8a0 100644
> --- a/discover/pxe-parser.c
> +++ b/discover/pxe-parser.c
> @@ -324,7 +324,7 @@ static void pxe_conf_parse_cb(struct load_url_result *result, void *data)
>  
>  	talloc_free(buf);
>  out_clean:
> -	if (result->cleanup_local)
> +	if (result && result->cleanup_local)
>  		unlink(result->local);
>  	talloc_free(conf);
>  }
diff mbox series

Patch

diff --git a/discover/pxe-parser.c b/discover/pxe-parser.c
index 5c80b1399973..d2ebaab0e8a0 100644
--- a/discover/pxe-parser.c
+++ b/discover/pxe-parser.c
@@ -324,7 +324,7 @@  static void pxe_conf_parse_cb(struct load_url_result *result, void *data)
 
 	talloc_free(buf);
 out_clean:
-	if (result->cleanup_local)
+	if (result && result->cleanup_local)
 		unlink(result->local);
 	talloc_free(conf);
 }