Skip to content

Commit 0940795

Browse files
nathanchancegregkh
authored andcommitted
ARM: davinci: da850-evm: Avoid NULL pointer dereference
commit 83a1cde upstream. With newer versions of GCC, there is a panic in da850_evm_config_emac() when booting multi_v5_defconfig in QEMU under the palmetto-bmc machine: Unable to handle kernel NULL pointer dereference at virtual address 00000020 pgd = (ptrval) [00000020] *pgd=00000000 Internal error: Oops: 5 [#1] PREEMPT ARM Modules linked in: CPU: 0 PID: 1 Comm: swapper Not tainted 5.15.0 #1 Hardware name: Generic DT based system PC is at da850_evm_config_emac+0x1c/0x120 LR is at do_one_initcall+0x50/0x1e0 The emac_pdata pointer in soc_info is NULL because davinci_soc_info only gets populated on davinci machines but da850_evm_config_emac() is called on all machines via device_initcall(). Move the rmii_en assignment below the machine check so that it is only dereferenced when running on a supported SoC. Fixes: bae1058 ("davinci: DA850/OMAP-L138 EVM: implement autodetect of RMII PHY") Signed-off-by: Nathan Chancellor <[email protected]> Reviewed-by: Arnd Bergmann <[email protected]> Reviewed-by: Bartosz Golaszewski <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/YcS4xVWs6bQlQSPC@archlinux-ax161/ Signed-off-by: Arnd Bergmann <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 68a38b0 commit 0940795

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

arch/arm/mach-davinci/board-da850-evm.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1101,11 +1101,13 @@ static int __init da850_evm_config_emac(void)
11011101
int ret;
11021102
u32 val;
11031103
struct davinci_soc_info *soc_info = &davinci_soc_info;
1104-
u8 rmii_en = soc_info->emac_pdata->rmii_en;
1104+
u8 rmii_en;
11051105

11061106
if (!machine_is_davinci_da850_evm())
11071107
return 0;
11081108

1109+
rmii_en = soc_info->emac_pdata->rmii_en;
1110+
11091111
cfg_chip3_base = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG);
11101112

11111113
val = __raw_readl(cfg_chip3_base);

0 commit comments

Comments
 (0)