diff options
author | Basavaraj Natikar <Basavaraj.Natikar@amd.com> | 2021-09-23 15:29:27 +0300 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2021-09-27 11:00:43 +0300 |
commit | 88a04049c08cd62e698bc1b1af2d09574b9e0aee (patch) | |
tree | 7ed29ed1e328189099779f462a969a7c88e7117d /drivers/hid/amd-sfh-hid | |
parent | 22d65765f211cc83186fd8b87521159f354c0da9 (diff) | |
download | linux-88a04049c08cd62e698bc1b1af2d09574b9e0aee.tar.xz |
HID: amd_sfh: Fix potential NULL pointer dereference
The cl_data field of a privdata must be allocated and updated before
using in amd_sfh_hid_client_init() function.
Hence handling NULL pointer cl_data accordingly.
Fixes: d46ef750ed58 ("HID: amd_sfh: Fix potential NULL pointer dereference")
Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/amd-sfh-hid')
-rw-r--r-- | drivers/hid/amd-sfh-hid/amd_sfh_pcie.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c index 9a1824757aae..05c007b213f2 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c +++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c @@ -251,21 +251,17 @@ static int amd_mp2_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i return rc; } - rc = amd_sfh_hid_client_init(privdata); - if (rc) - return rc; - privdata->cl_data = devm_kzalloc(&pdev->dev, sizeof(struct amdtp_cl_data), GFP_KERNEL); if (!privdata->cl_data) return -ENOMEM; - rc = devm_add_action_or_reset(&pdev->dev, amd_mp2_pci_remove, privdata); + mp2_select_ops(privdata); + + rc = amd_sfh_hid_client_init(privdata); if (rc) return rc; - mp2_select_ops(privdata); - - return 0; + return devm_add_action_or_reset(&pdev->dev, amd_mp2_pci_remove, privdata); } static int __maybe_unused amd_mp2_pci_resume(struct device *dev) |