HID: amd_sfh: Fix potential NULL pointer dereference
authorEvgeny Novikov <novikov@ispras.ru>
Tue, 1 Jun 2021 16:38:01 +0000 (19:38 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 7 Oct 2021 05:53:04 +0000 (07:53 +0200)
commit283e4bee701dfcd409dd293f19a268bb2bc8ff38
tree590d49b3638987d7a0d58cdeac6f52b7ae5c4cb9
parenta3d0bfc22a991effe7005bcb593f9f72ff866f41
HID: amd_sfh: Fix potential NULL pointer dereference

[ Upstream commit d46ef750ed58cbeeba2d9a55c99231c30a172764 ]

devm_add_action_or_reset() can suddenly invoke amd_mp2_pci_remove() at
registration that will cause NULL pointer dereference since
corresponding data is not initialized yet. The patch moves
initialization of data before devm_add_action_or_reset().

Found by Linux Driver Verification project (linuxtesting.org).

[jkosina@suse.cz: rebase]
Signed-off-by: Evgeny Novikov <novikov@ispras.ru>
Acked-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/hid/amd-sfh-hid/amd_sfh_pcie.c