Skip to content

Commit 88a0404

Browse files
basuamdJiri Kosina
authored andcommitted
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: d46ef75 ("HID: amd_sfh: Fix potential NULL pointer dereference") Signed-off-by: Basavaraj Natikar <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 22d6576 commit 88a0404

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

drivers/hid/amd-sfh-hid/amd_sfh_pcie.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -251,21 +251,17 @@ static int amd_mp2_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
251251
return rc;
252252
}
253253

254-
rc = amd_sfh_hid_client_init(privdata);
255-
if (rc)
256-
return rc;
257-
258254
privdata->cl_data = devm_kzalloc(&pdev->dev, sizeof(struct amdtp_cl_data), GFP_KERNEL);
259255
if (!privdata->cl_data)
260256
return -ENOMEM;
261257

262-
rc = devm_add_action_or_reset(&pdev->dev, amd_mp2_pci_remove, privdata);
258+
mp2_select_ops(privdata);
259+
260+
rc = amd_sfh_hid_client_init(privdata);
263261
if (rc)
264262
return rc;
265263

266-
mp2_select_ops(privdata);
267-
268-
return 0;
264+
return devm_add_action_or_reset(&pdev->dev, amd_mp2_pci_remove, privdata);
269265
}
270266

271267
static int __maybe_unused amd_mp2_pci_resume(struct device *dev)

0 commit comments

Comments
 (0)