Skip to content

Commit

Permalink
HID: amd_sfh: Fix potential NULL pointer dereference - take 2
Browse files Browse the repository at this point in the history
commit 88a0404 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: d46ef75 ("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>
  • Loading branch information
Basavaraj Natikar authored and gregkh committed Oct 7, 2021
1 parent fe6f7b7 commit 81971ea
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
Expand Up @@ -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[] = {
Expand Down

0 comments on commit 81971ea

Please sign in to comment.