]> git.ozlabs.org Git - petitboot/commitdiff
discover: pxe: Avoid dereferencing null pointer
authorJoel Stanley <joel@jms.id.au>
Tue, 6 Mar 2018 04:02:20 +0000 (14:32 +1030)
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>
Wed, 7 Mar 2018 05:24:31 +0000 (16:24 +1100)
When result is null, we may end up in the error handling path where we
try to dereference null to call cleanup_local. This adds a check for
result.

Found with scan-build.

Signed-off-by: Joel Stanley <joel@jms.id.au>
Reviewed-by: Cyril Bur <cyrilbur@gmail.com>
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
[Fixed up commit message typo]

discover/pxe-parser.c

index 5c80b1399973813f47db0f705fb4a3d0fba41ebd..d2ebaab0e8a0f07f2f1aeef8bd262762301980b8 100644 (file)
@@ -324,7 +324,7 @@ static void pxe_conf_parse_cb(struct load_url_result *result, void *data)
 
        talloc_free(buf);
 out_clean:
 
        talloc_free(buf);
 out_clean:
-       if (result->cleanup_local)
+       if (result && result->cleanup_local)
                unlink(result->local);
        talloc_free(conf);
 }
                unlink(result->local);
        talloc_free(conf);
 }