[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250220152747.GA2510987@rocinante>
Date: Fri, 21 Feb 2025 00:27:47 +0900
From: Krzysztof WilczyĆski <kw@...ux.com>
To: Christian Bruel <christian.bruel@...s.st.com>
Cc: manivannan.sadhasivam@...aro.org, kishon@...nel.org,
bhelgaas@...gle.com, cassel@...nel.org, Frank.Li@....com,
dlemoal@...nel.org, fabrice.gasnier@...s.st.com,
linux-pci@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] PCI: endpoint: pci-epf-test: Fix double free Oops
Hello,
> Fixes an oops found while testing the stm32_pcie ep driver with handling
> of PERST# deassertion:
>
> During EP initialization, pci_epf_test_alloc_space allocates all BARs,
> which are further freed if epc_set_bar fails (for instance, due to
> no free inbound window).
>
> However, when pci_epc_set_bar fails, the error path:
> pci_epc_set_bar -> pci_epf_free_space
> does not reset epf_test->reg[bar].
>
> Then, if the host reboots, PERST# deassertion restarts the BAR allocation
> sequence with the same allocation failure (no free inbound window),
> creating a double free situation since epf_test->reg[bar] was deallocated
> and is still non-NULL.
>
> Make sure that pci_epf_alloc_space/pci_epf_free_space are symmetric
> by resetting epf_test->reg[bar] when memory is deallocated.
Applied to endpoint, thank you!
Krzysztof
Powered by blists - more mailing lists