Skip to content

Commit 758c910

Browse files
michichkuba-moo
authored andcommitted
octeon_ep: cancel queued works in probe error path
If it fails to get the devices's MAC address, octep_probe exits while leaving the delayed work intr_poll_task queued. When the work later runs, it's a use after free. Move the cancelation of intr_poll_task from octep_remove into octep_device_cleanup. This does not change anything in the octep_remove flow, but octep_device_cleanup is called also in the octep_probe error path, where the cancelation is needed. Note that the cancelation of ctrl_mbox_task has to follow intr_poll_task's, because the ctrl_mbox_task may be queued by intr_poll_task. Fixes: 24d4333 ("octeon_ep: poll for control messages") Signed-off-by: Michal Schmidt <mschmidt@redhat.com> Link: https://lore.kernel.org/r/20230810150114.107765-5-mschmidt@redhat.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 607a7a4 commit 758c910

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/net/ethernet/marvell/octeon_ep/octep_main.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,6 +1038,10 @@ static void octep_device_cleanup(struct octep_device *oct)
10381038
{
10391039
int i;
10401040

1041+
oct->poll_non_ioq_intr = false;
1042+
cancel_delayed_work_sync(&oct->intr_poll_task);
1043+
cancel_work_sync(&oct->ctrl_mbox_task);
1044+
10411045
dev_info(&oct->pdev->dev, "Cleaning up Octeon Device ...\n");
10421046

10431047
for (i = 0; i < OCTEP_MAX_VF; i++) {
@@ -1205,9 +1209,6 @@ static void octep_remove(struct pci_dev *pdev)
12051209
unregister_netdev(netdev);
12061210

12071211
cancel_work_sync(&oct->tx_timeout_task);
1208-
oct->poll_non_ioq_intr = false;
1209-
cancel_delayed_work_sync(&oct->intr_poll_task);
1210-
cancel_work_sync(&oct->ctrl_mbox_task);
12111212
octep_device_cleanup(oct);
12121213
pci_release_mem_regions(pdev);
12131214
free_netdev(netdev);

0 commit comments

Comments
 (0)