From 116d15939ba3fafdd4859423527974b24c0054fe Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Tue, 1 Jul 2025 19:06:02 -0600 Subject: boot/android_ab.c: Make use of LBAF for printing lbaint_t When printing the contents of an lbaint_t variable we need to use LBAF to print it in order to get the correct format type depending on 32 or 64bit-ness. Furthermore, printed message should not be split as that makes finding them harder, so bring this back to a single line. Signed-off-by: Tom Rini Reviewed-by: Sam Protsenko Reviewed-by: Mattijs Korpershoek Link: https://lore.kernel.org/r/20250702010603.19354-1-trini@konsulko.com Signed-off-by: Mattijs Korpershoek --- boot/android_ab.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/boot/android_ab.c b/boot/android_ab.c index a287eac04fe..13e82dbcb7f 100644 --- a/boot/android_ab.c +++ b/boot/android_ab.c @@ -101,8 +101,7 @@ static int ab_control_create_from_disk(struct blk_desc *dev_desc, abc_blocks = DIV_ROUND_UP(sizeof(struct bootloader_control), part_info->blksz); if (abc_offset + abc_blocks > part_info->size) { - log_err("ANDROID: boot control partition too small. Need at"); - log_err(" least %lu blocks but have %lu blocks.\n", + log_err("ANDROID: boot control partition too small. Need at least %lu blocks but have " LBAF " blocks.\n", abc_offset + abc_blocks, part_info->size); return -EINVAL; } -- cgit v1.2.3 From d9a9b4e35272abe32e5ec843a6f72371b58a6504 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Tue, 1 Jul 2025 19:06:03 -0600 Subject: common/avb_verify.c: Make use of LBAF for printing lbaint_t When printing the contents of an lbaint_t variable we need to use LBAF to print it in order to get the correct format type depending on 32 or 64bit-ness. Signed-off-by: Tom Rini Reviewed-by: Sam Protsenko Reviewed-by: Mattijs Korpershoek Link: https://lore.kernel.org/r/20250702010603.19354-2-trini@konsulko.com Signed-off-by: Mattijs Korpershoek --- common/avb_verify.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/avb_verify.c b/common/avb_verify.c index cff9117d92f..29a3272579c 100644 --- a/common/avb_verify.c +++ b/common/avb_verify.c @@ -320,7 +320,7 @@ static unsigned long mmc_read_and_flush(struct mmc_part *part, } if ((start + sectors) > (part->info.start + part->info.size)) { sectors = part->info.start + part->info.size - start; - printf("%s: read sector aligned to partition bounds (%ld)\n", + printf("%s: read sector aligned to partition bounds (" LBAF ")\n", __func__, sectors); } @@ -363,7 +363,7 @@ static unsigned long mmc_write(struct mmc_part *part, lbaint_t start, } if ((start + sectors) > (part->info.start + part->info.size)) { sectors = part->info.start + part->info.size - start; - printf("%s: sector aligned to partition bounds (%ld)\n", + printf("%s: sector aligned to partition bounds (" LBAF ")\n", __func__, sectors); } if (unaligned) { -- cgit v1.2.3 From 89911825a2d3bbd1bc5d41b977aa24fb5b10f49d Mon Sep 17 00:00:00 2001 From: Sam Protsenko Date: Tue, 8 Jul 2025 23:23:42 -0500 Subject: dfu: Fix dfu_config_interfaces() for single interface DFU syntax As stated in DFU documentation [1], the device interface part might be missing in dfu_alt_info: dfu_alt_info The DFU setting for the USB download gadget with a semicolon separated string of information on each alternate: dfu_alt_info=";;....;" When several devices are used, the format is: - '='alternate list (';' separated) So in first case dfu_alt_info might look like something like this: dfu_alt_info="mmc 0=rawemmc raw 0 0x747c000 mmcpart 1;" And in second case (when the interface is missing): dfu_alt_info="rawemmc raw 0 0x747c000 mmcpart 1;" When the interface is not specified the 'dfu' command crashes when called using 'dfu 0' or 'dfu list' syntax: => dfu list "Synchronous Abort" handler, esr 0x96000006, far 0x0 That's happening due to incorrect string handling in dfu_config_interfaces(). In case when the interface is not specified in dfu_alt_info it triggers this corner case: d = strsep(&s, "="); // now d contains s, and s is NULL if (!d) break; a = strsep(&s, "&"); // s is already NULL, so a is NULL too if (!a) // corner case a = s; // a is NULL now which causes NULL pointer dereference later in this call, due to 'a' being NULL: part = skip_spaces(part); That's because as per strsep() behavior, when delimiter ("&") is not found, the token (a) becomes the entire string (s), and string (s) becomes NULL. To fix that issue assign "a = d" instead of "a = s", because at that point variable d actually contains previous s, which should be used in this case. [1] doc/usage/dfu.rst Fixes: commit febabe3ed4f4 ("dfu: allow to manage DFU on several devices") Signed-off-by: Sam Protsenko Reviewed-by: Mattijs Korpershoek Link: https://lore.kernel.org/r/20250709042342.13544-1-semen.protsenko@linaro.org Signed-off-by: Mattijs Korpershoek --- drivers/dfu/dfu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c index 756569217bb..eefdf44ec87 100644 --- a/drivers/dfu/dfu.c +++ b/drivers/dfu/dfu.c @@ -147,7 +147,7 @@ int dfu_config_interfaces(char *env) break; a = strsep(&s, "&"); if (!a) - a = s; + a = d; do { part = strsep(&a, ";"); part = skip_spaces(part); -- cgit v1.2.3