Re: [PATCH 4/4] PCI: endpoint: pci-ep-msi: Fix error unwind and prevent double alloc

Niklas Cassel <[email protected]>
Newsgroups dev.linux.lists.ntb,org.kernel.vger.linux-kernel,org.kernel.vger.linux-pci
Message-ID <aZMGNed0JChM9GEa@ryzen>
On Mon, Feb 16, 2026 at 12:09:14AM +0900, Koichiro Den wrote:
> pci_epf_alloc_doorbell() stores the allocated doorbell message array in
> epf->db_msg/epf->num_db before requesting MSI vectors. If MSI allocation
> fails, the array is freed but the EPF state may still point to freed
> memory.
> 
> Clear epf->db_msg and epf->num_db on the MSI allocation failure path so
> that later cleanup cannot double-free the array and callers can retry
> allocation.
> 
> Also return -EBUSY when doorbells have already been allocated to prevent
> leaking or overwriting an existing allocation.
> 
> Fixes: 1c3b002c6bf6 ("PCI: endpoint: Add RC-to-EP doorbell support using platform MSI controller")
> Reviewed-by: Frank Li <[email protected]>
> Signed-off-by: Koichiro Den <[email protected]>
> ---

Reviewed-by: Niklas Cassel <[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.