Skip to content

Commit d46ef75

Browse files
eunovmJiri Kosina
authored andcommitted
HID: amd_sfh: Fix potential NULL pointer dereference
devm_add_action_or_reset() can suddenly invoke amd_mp2_pci_remove() at registration that will cause NULL pointer dereference since corresponding data is not initialized yet. The patch moves initialization of data before devm_add_action_or_reset(). Found by Linux Driver Verification project (linuxtesting.org). [[email protected]: rebase] Signed-off-by: Evgeny Novikov <[email protected]> Acked-by: Basavaraj Natikar <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 0c8fbaa commit d46ef75

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,10 @@ 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+
254258
privdata->cl_data = devm_kzalloc(&pdev->dev, sizeof(struct amdtp_cl_data), GFP_KERNEL);
255259
if (!privdata->cl_data)
256260
return -ENOMEM;
@@ -261,7 +265,7 @@ static int amd_mp2_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
261265

262266
mp2_select_ops(privdata);
263267

264-
return amd_sfh_hid_client_init(privdata);
268+
return 0;
265269
}
266270

267271
static int __maybe_unused amd_mp2_pci_resume(struct device *dev)

0 commit comments

Comments
 (0)