summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBasavaraj Natikar <Basavaraj.Natikar@amd.com>2021-09-23 17:59:27 +0530
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-10-07 07:53:19 +0200
commit81971ea5ec5c37509cc2a2f520ba4127e973fb41 (patch)
treea89d1cb18239e4eb19aad47e686b03cd31e0ae02
parentfe6f7b77796e6ed21c4f53cfaebedfe12316f5e9 (diff)
HID: amd_sfh: Fix potential NULL pointer dereference - take 2
commit 88a04049c08cd62e698bc1b1af2d09574b9e0aee upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/hid/amd-sfh-hid/amd_sfh_pcie.c12
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 4069b813c6c3..1b4a192b19e5 100644
--- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
+++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
@@ -235,21 +235,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 const struct pci_device_id amd_mp2_pci_tbl[] = {