Re: [PATCH] tg3: Fix peer device double put in tg3_find_peer()

From: Simon Horman

Date: Sun Sep 20 2026 - 05:36:54 EST


On Thu, Sep 17, 2026 at 10:51:04AM +0000, Wentao Liang wrote:
> pci_get_slot() returns a device with its reference count incremented.
> When the loop ends on tp->pdev (which happens when the adapter sits at
> PCI function 7 and no other function is present) that reference has
> already been dropped inside the loop, but the trailing pci_dev_put()
> drops it a second time, underflowing the refcount of tp->pdev.
>
> Treat a loop end on tp->pdev as single-port mode, just like the
> existing !peer case.
>
> Fixes: 16fe9d74f14e ("[TG3]: Fix 5704 single-port mode")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>

Hi,

I agree with your analysis of the logic.
But I wonder if it can occur in practice:
can such a device actually be presented to the Kernel?