diff mbox series

[01/18] armv8: fsl-layerscape: check for crypto node first in fdt_fixup_remove_jr

Message ID 20230412073830.13928-2-matt@traverse.com.au
State Accepted
Commit 8586a938682dbb0da669073c851e1f5ac62c37fe
Delegated to: Peng Fan
Headers show
Series Synchronise LS1088A/Ten64 device tree with Linux | expand

Commit Message

Mathew McBride April 12, 2023, 7:38 a.m. UTC
This a problem I found while updating the U-Boot fsl-ls1088a.dtsi
to match the Linux version.

fdt_fixup_remove_jr did not check whether there was a "crypto"
alias in the device tree before calling more fdt_* functions,
which resulted in a crash.

Fixes: a797f274
("ARMv8/sec_firmware : Update chosen/kaslr-seed with random number")

Signed-off-by: Mathew McBride <matt@traverse.com.au>
---
 arch/arm/cpu/armv8/fsl-layerscape/fdt.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Peng Fan (OSS) April 28, 2023, 3:24 a.m. UTC | #1
On 4/12/2023 3:38 PM, Mathew McBride wrote:
> This a problem I found while updating the U-Boot fsl-ls1088a.dtsi
> to match the Linux version.
> 
> fdt_fixup_remove_jr did not check whether there was a "crypto"
> alias in the device tree before calling more fdt_* functions,
> which resulted in a crash.
> 
> Fixes: a797f274
> ("ARMv8/sec_firmware : Update chosen/kaslr-seed with random number")
> 
> Signed-off-by: Mathew McBride <matt@traverse.com.au>

Reviewed-by: Peng Fan <peng.fan@nxp.com>

> ---
>   arch/arm/cpu/armv8/fsl-layerscape/fdt.c | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/arch/arm/cpu/armv8/fsl-layerscape/fdt.c b/arch/arm/cpu/armv8/fsl-layerscape/fdt.c
> index 4f91db49ee..22ce699216 100644
> --- a/arch/arm/cpu/armv8/fsl-layerscape/fdt.c
> +++ b/arch/arm/cpu/armv8/fsl-layerscape/fdt.c
> @@ -387,6 +387,10 @@ void fdt_fixup_remove_jr(void *blob)
>   	u64 jr_offset, used_jr;
>   	fdt32_t *reg;
>   
> +	/* Return if crypto node not found */
> +	if (crypto_node < 0)
> +		return;
> +
>   	used_jr = sec_firmware_used_jobring_offset();
>   	fdt_support_default_count_cells(blob, crypto_node, &addr_cells, NULL);
>
diff mbox series

Patch

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/fdt.c b/arch/arm/cpu/armv8/fsl-layerscape/fdt.c
index 4f91db49ee..22ce699216 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/fdt.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/fdt.c
@@ -387,6 +387,10 @@  void fdt_fixup_remove_jr(void *blob)
 	u64 jr_offset, used_jr;
 	fdt32_t *reg;
 
+	/* Return if crypto node not found */
+	if (crypto_node < 0)
+		return;
+
 	used_jr = sec_firmware_used_jobring_offset();
 	fdt_support_default_count_cells(blob, crypto_node, &addr_cells, NULL);