* [PATCH v3] cmd: abootimg: Prevent use of unintialised variable
@ 2025-06-26 8:58 Andrew Goodbody
2025-06-27 6:49 ` Mattijs Korpershoek
0 siblings, 1 reply; 2+ messages in thread
From: Andrew Goodbody @ 2025-06-26 8:58 UTC (permalink / raw)
To: Tom Rini, Mattijs Korpershoek; +Cc: u-boot, Andrew Goodbody
Initiaise vhdr to prevent its use when uninitialised.
This issue was found with Smatch.
Fixes: 636da2039aea (android: boot: support boot image header version 3 and 4)
Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
---
Changes in v3:
- Just initialise the variable rather than exit early
- Link to v2: https://lore.kernel.org/r/20250625-abootimg_fix-v2-1-0d295dc1f1e2@linaro.org
Changes in v2:
- Add unmap_sysmem(hdr) in the new exit path
- Link to v1: https://lore.kernel.org/r/20250625-abootimg_fix-v1-1-ce1645ac9879@linaro.org
---
cmd/abootimg.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/cmd/abootimg.c b/cmd/abootimg.c
index ae7a1a7c83b..9ae87581d2c 100644
--- a/cmd/abootimg.c
+++ b/cmd/abootimg.c
@@ -95,7 +95,7 @@ static int abootimg_get_dtb_load_addr(int argc, char *const argv[])
return CMD_RET_USAGE;
struct andr_image_data img_data = {0};
const struct andr_boot_img_hdr_v0 *hdr;
- const struct andr_vnd_boot_img_hdr *vhdr;
+ const struct andr_vnd_boot_img_hdr *vhdr = NULL;
hdr = map_sysmem(abootimg_addr(), sizeof(*hdr));
if (get_avendor_bootimg_addr() != -1)
---
base-commit: 903eb123236ccbd8ef05d43507a2a910b785bd56
change-id: 20250625-abootimg_fix-51600dc8356a
Best regards,
--
Andrew Goodbody <andrew.goodbody@linaro.org>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v3] cmd: abootimg: Prevent use of unintialised variable
2025-06-26 8:58 [PATCH v3] cmd: abootimg: Prevent use of unintialised variable Andrew Goodbody
@ 2025-06-27 6:49 ` Mattijs Korpershoek
0 siblings, 0 replies; 2+ messages in thread
From: Mattijs Korpershoek @ 2025-06-27 6:49 UTC (permalink / raw)
To: Andrew Goodbody, Tom Rini; +Cc: u-boot, Andrew Goodbody
Hi Andrew,
Thank you for the patch.
On Thu, Jun 26, 2025 at 09:58, Andrew Goodbody <andrew.goodbody@linaro.org> wrote:
> Initiaise vhdr to prevent its use when uninitialised.
s/Initiaise/Initialise/: will fix when applying.
>
> This issue was found with Smatch.
>
> Fixes: 636da2039aea (android: boot: support boot image header version 3 and 4)
> Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
> ---
> Changes in v3:
> - Just initialise the variable rather than exit early
> - Link to v2: https://lore.kernel.org/r/20250625-abootimg_fix-v2-1-0d295dc1f1e2@linaro.org
>
> Changes in v2:
> - Add unmap_sysmem(hdr) in the new exit path
> - Link to v1: https://lore.kernel.org/r/20250625-abootimg_fix-v1-1-ce1645ac9879@linaro.org
> ---
> cmd/abootimg.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/cmd/abootimg.c b/cmd/abootimg.c
> index ae7a1a7c83b..9ae87581d2c 100644
> --- a/cmd/abootimg.c
> +++ b/cmd/abootimg.c
> @@ -95,7 +95,7 @@ static int abootimg_get_dtb_load_addr(int argc, char *const argv[])
> return CMD_RET_USAGE;
> struct andr_image_data img_data = {0};
> const struct andr_boot_img_hdr_v0 *hdr;
> - const struct andr_vnd_boot_img_hdr *vhdr;
> + const struct andr_vnd_boot_img_hdr *vhdr = NULL;
>
> hdr = map_sysmem(abootimg_addr(), sizeof(*hdr));
> if (get_avendor_bootimg_addr() != -1)
>
> ---
> base-commit: 903eb123236ccbd8ef05d43507a2a910b785bd56
> change-id: 20250625-abootimg_fix-51600dc8356a
>
> Best regards,
> --
> Andrew Goodbody <andrew.goodbody@linaro.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-06-27 6:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-26 8:58 [PATCH v3] cmd: abootimg: Prevent use of unintialised variable Andrew Goodbody
2025-06-27 6:49 ` Mattijs Korpershoek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox