Skip to contentSkip to conversation

smbios: Do not fall back on devicetree without valid mapping

PATCH In review Mark Kettenis 5 participants 5 messages May 9 – May 15 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 smbios: Do not fall back on devicetree without valid mapping

The smbios_get_val_si() function may get called for a sysinfo property for which there is no mapping to a devicetree property. Avoid a NULL pointer dereference in this case by skipping the read of the mapped property from the device tree.

Fixes 83b28b55d74f ("smbios: add support for dynamic generation of Type 9 system slot tables")
---
 lib/smbios.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/smbios.c +1 -1
index d5f18c8bd69..906d2753517 100644
@@ -292,7 +292,7 @@ static int smbios_get_val_si(struct smbios_ctx * __maybe_unused ctx,
 
 	/* If the node is still missing, try with the mapping values */
 	nprop = convert_sysinfo_to_dt(ctx->subnode_name, prop);
-	if (!ofnode_read_u32(ofnode_root(), nprop->dt_str, &val))
+	if (nprop && !ofnode_read_u32(ofnode_root(), nprop->dt_str, &val))
 		return val;
 #endif
 	return val_def;
Signature · 1 line
2.53.0
Reviewed-by on v1 1/1
#1 lore raw

Thanks Mark,

Quoted 9 lines · Mark Kettenis

The smbios_get_val_si() function may get called for a sysinfo property for which there is no mapping to a devicetree property. Avoid a NULL pointer dereference in this case by skipping the read of the mapped property from the device tree.

Fixes 83b28b55d74f ("smbios: add support for dynamic generation of Type 9 system slot tables")

---

Quoted 19 lines
 lib/smbios.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/smbios.c +1 -2
index d5f18c8bd69..906d2753517 100644
@@ -292,7 +292,7 @@ static int smbios_get_val_si(struct smbios_ctx * __maybe_unused ctx,
 
        /* If the node is still missing, try with the mapping values */
        nprop = convert_sysinfo_to_dt(ctx->subnode_name, prop);
-       if (!ofnode_read_u32(ofnode_root(), nprop->dt_str, &val))
+       if (nprop && !ofnode_read_u32(ofnode_root(), nprop->dt_str, &val))
                return val;
 #endif
        return val_def;
--

2.53.0

Reviewed-by on v1 1/1
#2 lore raw
In reply to Mark Kettenis

Hi Mark,

Quoted 16 lines · Mark Kettenis

smbios: Do not fall back on devicetree without valid mapping

The smbios_get_val_si() function may get called for a sysinfo property for which there is no mapping to a devicetree property. Avoid a NULL pointer dereference in this case by skipping the read of the mapped property from the device tree.

Fixes 83b28b55d74f ("smbios: add support for dynamic generation of Type 9 system slot tables")

lib/smbios.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)

lib/smbios.c static int smbios_get_val_si(struct smbios_ctx * __maybe_unused ctx, · line 296

Quoted 6 lines
lib/smbios.c +1 -1
@@ -292,7 +292,7 @@ static int smbios_get_val_si(struct smbios_ctx * __maybe_unused ctx,
 
      /* If the node is still missing, try with the mapping values */
      nprop = convert_sysinfo_to_dt(ctx->subnode_name, prop);
-     if (!ofnode_read_u32(ofnode_root(), nprop->dt_str, &val))
+     if (nprop && !ofnode_read_u32(ofnode_root(), nprop->dt_str, &val))
              return val;

Regards,
Simon

Reviewed-by on v1 1/1
#3 lore raw
In reply to Mark Kettenis

Hi Mark,

Quoted 6 lines · Mark Kettenis

The smbios_get_val_si() function may get called for a sysinfo property for which there is no mapping to a devicetree property. Avoid a NULL pointer dereference in this case by skipping the read of the mapped property from the device tree.

Quoted 6 lines
Fixes 83b28b55d74f ("smbios: add support for dynamic generation of Type 9 system slot tables")
---
 lib/smbios.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Thanks for fixing this.

Raymond

Quoted 16 lines
lib/smbios.c +1 -2
index d5f18c8bd69..906d2753517 100644
@@ -292,7 +292,7 @@ static int smbios_get_val_si(struct smbios_ctx * __maybe_unused ctx,
 
        /* If the node is still missing, try with the mapping values */
        nprop = convert_sysinfo_to_dt(ctx->subnode_name, prop);
-       if (!ofnode_read_u32(ofnode_root(), nprop->dt_str, &val))
+       if (nprop && !ofnode_read_u32(ofnode_root(), nprop->dt_str, &val))
                return val;
 #endif
        return val_def;
--

2.53.0

#4 lore raw
In reply to Mark Kettenis
Quoted 6 lines · Mark Kettenis

The smbios_get_val_si() function may get called for a sysinfo property for which there is no mapping to a devicetree property. Avoid a NULL pointer dereference in this case by skipping the read of the mapped property from the device tree.

Applied to u-boot/master, thanks!

[1/1] smbios: Do not fall back on devicetree without valid mapping

      commit: 215496fec59b3fa09256b4fb62f92af46e2ec7f9
Signature · 1 line
Tom