diff mbox series

board: libre-computer: check interface before comparing it in set_dfu_alt_info()

Message ID 20250403-u-boot-fix-set-dfu-alt-info-interface-v1-1-1fdd12463186@linaro.org
State New
Headers show
Series board: libre-computer: check interface before comparing it in set_dfu_alt_info() | expand

Commit Message

Neil Armstrong April 3, 2025, 4:03 p.m. UTC
When set_dfu_alt_info() is called, interface can be NULL when called for
the EFI capsule, so check it before calling it with strcmp().

Fixes: 12ea40d29dc ("ARM: meson: add support for Libre Computer aml-s905d3-cc")
Fixes: 9e6e6b034b1 ("ARM: meson: add support for Libre Computer aml-a311d-cc")
Fixes: 75c87c6cbc0 ("board: libre-computer: aml-s805x-cc: Enable capsule updates")
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
---
 board/libre-computer/aml-a311d-cc/aml-a311d-cc.c   | 2 +-
 board/libre-computer/aml-s805x-ac/aml-s805x-ac.c   | 2 +-
 board/libre-computer/aml-s905d3-cc/aml-s905d3-cc.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)


---
base-commit: f59fb9846c5a1d129f78b2945a094477388fd346
change-id: 20250403-u-boot-fix-set-dfu-alt-info-interface-9be8ea5e2bc1

Best regards,

Comments

Ilias Apalodimas April 3, 2025, 4:46 p.m. UTC | #1
On Thu, 3 Apr 2025 at 19:03, Neil Armstrong <neil.armstrong@linaro.org> wrote:
>
> When set_dfu_alt_info() is called, interface can be NULL when called for
> the EFI capsule, so check it before calling it with strcmp().
>
> Fixes: 12ea40d29dc ("ARM: meson: add support for Libre Computer aml-s905d3-cc")
> Fixes: 9e6e6b034b1 ("ARM: meson: add support for Libre Computer aml-a311d-cc")
> Fixes: 75c87c6cbc0 ("board: libre-computer: aml-s805x-cc: Enable capsule updates")
> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
> ---
>  board/libre-computer/aml-a311d-cc/aml-a311d-cc.c   | 2 +-
>  board/libre-computer/aml-s805x-ac/aml-s805x-ac.c   | 2 +-
>  board/libre-computer/aml-s905d3-cc/aml-s905d3-cc.c | 2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/board/libre-computer/aml-a311d-cc/aml-a311d-cc.c b/board/libre-computer/aml-a311d-cc/aml-a311d-cc.c
> index e45cfd5d8a3885683dd6b1d0eea03084dc6dfdb5..294f78858a7848fe8255c9b9b42e2f556a6e05d1 100644
> --- a/board/libre-computer/aml-a311d-cc/aml-a311d-cc.c
> +++ b/board/libre-computer/aml-a311d-cc/aml-a311d-cc.c
> @@ -29,7 +29,7 @@ struct efi_capsule_update_info update_info = {
>  #if IS_ENABLED(CONFIG_SET_DFU_ALT_INFO)
>  void set_dfu_alt_info(char *interface, char *devstr)
>  {
> -       if (strcmp(interface, "ram") == 0)
> +       if (interface && strcmp(interface, "ram") == 0)
>                 env_set("dfu_alt_info", "fitimage ram 0x08080000 0x4000000");
>         else if (IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_SUPPORT))
>                 env_set("dfu_alt_info", update_info.dfu_string);
> diff --git a/board/libre-computer/aml-s805x-ac/aml-s805x-ac.c b/board/libre-computer/aml-s805x-ac/aml-s805x-ac.c
> index 94cf5b4361fac5003dded2f8dc2bfc9be7630099..1ec9a5b401e210045f1b13720f1e5c16e1f7f86b 100644
> --- a/board/libre-computer/aml-s805x-ac/aml-s805x-ac.c
> +++ b/board/libre-computer/aml-s805x-ac/aml-s805x-ac.c
> @@ -36,7 +36,7 @@ struct efi_capsule_update_info update_info = {
>  #if IS_ENABLED(CONFIG_SET_DFU_ALT_INFO)
>  void set_dfu_alt_info(char *interface, char *devstr)
>  {
> -       if (strcmp(interface, "ram") == 0)
> +       if (interface && strcmp(interface, "ram") == 0)
>                 env_set("dfu_alt_info", "fitimage ram 0x08080000 0x4000000");
>         else if (IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_SUPPORT))
>                 env_set("dfu_alt_info", update_info.dfu_string);
> diff --git a/board/libre-computer/aml-s905d3-cc/aml-s905d3-cc.c b/board/libre-computer/aml-s905d3-cc/aml-s905d3-cc.c
> index f641db5a494f358ed89591fae06e66eb18f85709..b552035ee03a7b848455ae6564688b4a12e02326 100644
> --- a/board/libre-computer/aml-s905d3-cc/aml-s905d3-cc.c
> +++ b/board/libre-computer/aml-s905d3-cc/aml-s905d3-cc.c
> @@ -29,7 +29,7 @@ struct efi_capsule_update_info update_info = {
>  #if IS_ENABLED(CONFIG_SET_DFU_ALT_INFO)
>  void set_dfu_alt_info(char *interface, char *devstr)
>  {
> -       if (strcmp(interface, "ram") == 0)
> +       if (interface && strcmp(interface, "ram") == 0)
>                 env_set("dfu_alt_info", "fitimage ram 0x08080000 0x4000000");
>         else if (IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_SUPPORT))
>                 env_set("dfu_alt_info", update_info.dfu_string);
>
> ---
> base-commit: f59fb9846c5a1d129f78b2945a094477388fd346
> change-id: 20250403-u-boot-fix-set-dfu-alt-info-interface-9be8ea5e2bc1
>
> Best regards,
> --
> Neil Armstrong <neil.armstrong@linaro.org>
>

Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Neil Armstrong April 4, 2025, 8:40 a.m. UTC | #2
Hi,

On Thu, 03 Apr 2025 18:03:21 +0200, Neil Armstrong wrote:
> When set_dfu_alt_info() is called, interface can be NULL when called for
> the EFI capsule, so check it before calling it with strcmp().
> 
> 

Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-amlogic (u-boot-amlogic)

[1/1] board: libre-computer: check interface before comparing it in set_dfu_alt_info()
      https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/c5fd2c7ac7fa4835339ea09ead2884794314c9d8
diff mbox series

Patch

diff --git a/board/libre-computer/aml-a311d-cc/aml-a311d-cc.c b/board/libre-computer/aml-a311d-cc/aml-a311d-cc.c
index e45cfd5d8a3885683dd6b1d0eea03084dc6dfdb5..294f78858a7848fe8255c9b9b42e2f556a6e05d1 100644
--- a/board/libre-computer/aml-a311d-cc/aml-a311d-cc.c
+++ b/board/libre-computer/aml-a311d-cc/aml-a311d-cc.c
@@ -29,7 +29,7 @@  struct efi_capsule_update_info update_info = {
 #if IS_ENABLED(CONFIG_SET_DFU_ALT_INFO)
 void set_dfu_alt_info(char *interface, char *devstr)
 {
-	if (strcmp(interface, "ram") == 0)
+	if (interface && strcmp(interface, "ram") == 0)
 		env_set("dfu_alt_info", "fitimage ram 0x08080000 0x4000000");
 	else if (IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_SUPPORT))
 		env_set("dfu_alt_info", update_info.dfu_string);
diff --git a/board/libre-computer/aml-s805x-ac/aml-s805x-ac.c b/board/libre-computer/aml-s805x-ac/aml-s805x-ac.c
index 94cf5b4361fac5003dded2f8dc2bfc9be7630099..1ec9a5b401e210045f1b13720f1e5c16e1f7f86b 100644
--- a/board/libre-computer/aml-s805x-ac/aml-s805x-ac.c
+++ b/board/libre-computer/aml-s805x-ac/aml-s805x-ac.c
@@ -36,7 +36,7 @@  struct efi_capsule_update_info update_info = {
 #if IS_ENABLED(CONFIG_SET_DFU_ALT_INFO)
 void set_dfu_alt_info(char *interface, char *devstr)
 {
-	if (strcmp(interface, "ram") == 0)
+	if (interface && strcmp(interface, "ram") == 0)
 		env_set("dfu_alt_info", "fitimage ram 0x08080000 0x4000000");
 	else if (IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_SUPPORT))
 		env_set("dfu_alt_info", update_info.dfu_string);
diff --git a/board/libre-computer/aml-s905d3-cc/aml-s905d3-cc.c b/board/libre-computer/aml-s905d3-cc/aml-s905d3-cc.c
index f641db5a494f358ed89591fae06e66eb18f85709..b552035ee03a7b848455ae6564688b4a12e02326 100644
--- a/board/libre-computer/aml-s905d3-cc/aml-s905d3-cc.c
+++ b/board/libre-computer/aml-s905d3-cc/aml-s905d3-cc.c
@@ -29,7 +29,7 @@  struct efi_capsule_update_info update_info = {
 #if IS_ENABLED(CONFIG_SET_DFU_ALT_INFO)
 void set_dfu_alt_info(char *interface, char *devstr)
 {
-	if (strcmp(interface, "ram") == 0)
+	if (interface && strcmp(interface, "ram") == 0)
 		env_set("dfu_alt_info", "fitimage ram 0x08080000 0x4000000");
 	else if (IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_SUPPORT))
 		env_set("dfu_alt_info", update_info.dfu_string);