Skip to content

Commit

Permalink
ON-16252: Fix ef10ct pci_dev use after free
Browse files Browse the repository at this point in the history
Increment refcount of ef10ct pci_dev in ef10ct_get_pci_dev as required
by efhw function interface. Care is taken to do this while auxbus is
present otherwise the pci device may have already been freed by the
sfc-linux-net.
  • Loading branch information
ligallag-amd committed Dec 20, 2024
1 parent 6e4cd22 commit 467ee38
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/lib/efhw/ef10ct/ef10ct.c
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,11 @@ ef10ct_get_pci_dev(struct efhw_nic* nic)

AUX_PRE(dev, edev, cli, nic, rc)
rc = edev->llct_ops->base_ops->get_param(cli, EFX_PCI_DEV, &val);
/* Ensure auxbus is still present when we increment the refcount to the pci
* dev. This means it will not be used after free. */
if( rc >= 0 )
pci_dev_get(val.pci_dev);

AUX_POST(dev, edev, cli, nic, rc);

if( rc < 0 )
Expand Down

0 comments on commit 467ee38

Please sign in to comment.