]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
ARM: davinci: da850-evm: Avoid NULL pointer dereference
authorNathan Chancellor <nathan@kernel.org>
Thu, 23 Dec 2021 22:21:41 +0000 (15:21 -0700)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 27 Apr 2022 10:01:03 +0000 (12:01 +0200)
commitef2111180369e10a46dd3a66f188bfebb5543612
tree2395067595e383eaa88934b551de778b9d5deacd
parent27a08dc13495e9a46e9eeb6b7a1e367dd83acf13
ARM: davinci: da850-evm: Avoid NULL pointer dereference

BugLink: https://bugs.launchpad.net/bugs/1969857
commit 83a1cde5c74bfb44b49cb2a940d044bb2380f4ea 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: bae105879f2f ("davinci: DA850/OMAP-L138 EVM: implement autodetect of RMII PHY")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/YcS4xVWs6bQlQSPC@archlinux-ax161/
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
arch/arm/mach-davinci/board-da850-evm.c