]> git.baikalelectronics.ru Git - kernel.git/commitdiff
HID: amd_sfh: Fix potential NULL pointer dereference
authorBasavaraj Natikar <Basavaraj.Natikar@amd.com>
Thu, 23 Sep 2021 12:29:27 +0000 (17:59 +0530)
committerJiri Kosina <jkosina@suse.cz>
Mon, 27 Sep 2021 08:00:43 +0000 (10:00 +0200)
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: a8f477b9ac1d ("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>
drivers/hid/amd-sfh-hid/amd_sfh_pcie.c

index 9a1824757aae9d8f79066f1bf0b2bcb066f8f042..05c007b213f245ac202ab4399cd3e7c16dd4aab5 100644 (file)
@@ -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)