Skip to contentSkip to conversation

arm/efi: Fix null pointer dereference

PATCH In review Luca Fancellu 3 participants 3 messages Oct 11, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm/efi: Fix null pointer dereference

Fix for commit 60649d443dc395243e74d2b3e05594ac0c43cfe3 that introduces a null pointer dereference when the fdt_node_offset_by_compatible is called with "fdt" argument null.

Fixes 60649d443d ("arm/efi: Introduce xen,uefi-cfg-load DT property")
---
 xen/arch/arm/efi/efi-boot.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
xen/arch/arm/efi/efi-boot.h +2 -1
index a3e46453d4..e63dafac26 100644
@@ -593,7 +593,8 @@ static bool __init efi_arch_use_config_file(EFI_SYSTEM_TABLE *SystemTable)
     dtbfile.ptr = fdt;
     dtbfile.need_to_free = false; /* Config table memory can't be freed. */
 
-    if ( fdt_node_offset_by_compatible(fdt, 0, "multiboot,module") > 0 )
+    if ( fdt &&
+         (fdt_node_offset_by_compatible(fdt, 0, "multiboot,module") > 0) )
     {
         /* Locate chosen node */
         int node = fdt_subnode_offset(fdt, 0, "chosen");
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw

Hi Luca,

Quoted 10 lines · Luca Fancellu

Fix for commit 60649d443dc395243e74d2b3e05594ac0c43cfe3 that introduces a null pointer dereference when the fdt_node_offset_by_compatible is called with "fdt" argument null.

Fixes 60649d443d ("arm/efi: Introduce xen,uefi-cfg-load DT property")

Cheers
Bertrand

Quoted 21 lines

---
xen/arch/arm/efi/efi-boot.h | 3 ++-

1 file changed, 2 insertions(+), 1 deletion(-)
xen/arch/arm/efi/efi-boot.h +2 -1
index a3e46453d4..e63dafac26 100644
@@ -593,7 +593,8 @@ static bool __init efi_arch_use_config_file(EFI_SYSTEM_TABLE *SystemTable)
    dtbfile.ptr = fdt;
    dtbfile.need_to_free = false; /* Config table memory can't be freed. */
 
-    if ( fdt_node_offset_by_compatible(fdt, 0, "multiboot,module") > 0 )
+    if ( fdt &&
+         (fdt_node_offset_by_compatible(fdt, 0, "multiboot,module") > 0) )
    {
        /* Locate chosen node */
        int node = fdt_subnode_offset(fdt, 0, "chosen");
Signature · 1 line
2.17.1
Reviewed-by
#2 lore raw
Quoted 9 lines · Bertrand Marquis

Hi Luca,

Quoted 7 lines · Luca Fancellu

Fix for commit 60649d443dc395243e74d2b3e05594ac0c43cfe3 that introduces a null pointer dereference when the fdt_node_offset_by_compatible is called with "fdt" argument null.

Quoted 4 lines
Quoted 3 lines
Fixes 60649d443d ("arm/efi: Introduce xen,uefi-cfg-load DT property")
Quoted 22 lines
Quoted 21 lines

---
xen/arch/arm/efi/efi-boot.h | 3 ++-

1 file changed, 2 insertions(+), 1 deletion(-)
xen/arch/arm/efi/efi-boot.h +2 -1
index a3e46453d4..e63dafac26 100644
@@ -593,7 +593,8 @@ static bool __init efi_arch_use_config_file(EFI_SYSTEM_TABLE *SystemTable)
    dtbfile.ptr = fdt;
    dtbfile.need_to_free = false; /* Config table memory can't be freed. */
 
-    if ( fdt_node_offset_by_compatible(fdt, 0, "multiboot,module") > 0 )
+    if ( fdt &&
+         (fdt_node_offset_by_compatible(fdt, 0, "multiboot,module") > 0) )
    {
        /* Locate chosen node */
        int node = fdt_subnode_offset(fdt, 0, "chosen");
Signature · 1 line
2.17.1