]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
efi_loader: Prevent dereferencing NULL pointer
authorAndrew Goodbody <andrew.goodbody@linaro.org>
Wed, 2 Jul 2025 10:01:36 +0000 (11:01 +0100)
committerIlias Apalodimas <ilias.apalodimas@linaro.org>
Thu, 3 Jul 2025 08:32:49 +0000 (11:32 +0300)
Taking the first goto error: in file_open could either result in an
attempt to dereference fh when NULL or else free fh->path which has
not been assigned to and so will be unknown. Avoid both of these
problems by passing path to free instead of fh->path.

This issue found by Smatch.

Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
lib/efi_loader/efi_file.c

index 7d81da8f2d813a0d7aec2d8583caf7074f78042e..19b43c4a6250b97f58679b7cc95397882330a21e 100644 (file)
@@ -248,7 +248,7 @@ static struct efi_file_handle *file_open(struct file_system *fs,
        return &fh->base;
 
 error:
-       free(fh->path);
+       free(path);
        free(fh);
        return NULL;
 }