In the Linux kernel, the following vulnerability has been resolved:
firmware: dmi-sysfs: Fix null-ptr-deref in dmisysfsregister_handle
KASAN reported a null-ptr-deref error:
KASAN: null-ptr-deref in range [0x0000000000000008-0x000000000000000f] CPU: 0 PID: 1373 Comm: modprobe Hardware name: QEMU Standard PC (i440FX + PIIX, 1996) RIP: 0010:dmisysfsentryrelease ... Call Trace: <TASK> kobjectput dmisysfsregisterhandle (drivers/firmware/dmi-sysfs.c:540) dmisysfs dmidecodetable (drivers/firmware/dmiscan.c:133) dmiwalk (drivers/firmware/dmiscan.c:1115) dmisysfsinit (drivers/firmware/dmi-sysfs.c:149) dmisysfs dooneinitcall (init/main.c:1296) ... Kernel panic - not syncing: Fatal exception Kernel Offset: 0x4000000 from 0xffffffff81000000 ---[ end Kernel panic - not syncing: Fatal exception ]---
It is because previous patch added kobjectput() to release the memory which will call dmisysfsentryrelease() and list_del().
However, listaddtail(entry->list) is called after the error block, so the list_head is uninitialized and cannot be deleted.
Move error handling to after listaddtail to fix this.