public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] PCI: dwc: ep: Return -ENOMEM for allocation failures
@ 2025-03-05 15:00 Dan Carpenter
  2025-03-05 15:53 ` Krzysztof Wilczyński
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Dan Carpenter @ 2025-03-05 15:00 UTC (permalink / raw)
  To: Manivannan Sadhasivam
  Cc: Jingoo Han, Lorenzo Pieralisi, Krzysztof Wilczyński,
	Rob Herring, Bjorn Helgaas, Vidya Sagar, Frank Li, Niklas Cassel,
	linux-pci, linux-kernel, kernel-janitors

If the bitmap allocations fail then dw_pcie_ep_init_registers() currently
returns success.  Return -ENOMEM instead.

Fixes: 869bc5253406 ("PCI: dwc: ep: Fix DBI access failure for drivers requiring refclk from host")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/pci/controller/dwc/pcie-designware-ep.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c
index 20f2436c7091..1b873d486b2d 100644
--- a/drivers/pci/controller/dwc/pcie-designware-ep.c
+++ b/drivers/pci/controller/dwc/pcie-designware-ep.c
@@ -908,6 +908,7 @@ int dw_pcie_ep_init_registers(struct dw_pcie_ep *ep)
 	if (ret)
 		return ret;
 
+	ret = -ENOMEM;
 	if (!ep->ib_window_map) {
 		ep->ib_window_map = devm_bitmap_zalloc(dev, pci->num_ib_windows,
 						       GFP_KERNEL);
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] PCI: dwc: ep: Return -ENOMEM for allocation failures
  2025-03-05 15:00 [PATCH] PCI: dwc: ep: Return -ENOMEM for allocation failures Dan Carpenter
@ 2025-03-05 15:53 ` Krzysztof Wilczyński
  2025-03-05 16:10 ` Krzysztof Wilczyński
  2025-03-13  6:03 ` Manivannan Sadhasivam
  2 siblings, 0 replies; 4+ messages in thread
From: Krzysztof Wilczyński @ 2025-03-05 15:53 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Manivannan Sadhasivam, Jingoo Han, Lorenzo Pieralisi, Rob Herring,
	Bjorn Helgaas, Vidya Sagar, Frank Li, Niklas Cassel, linux-pci,
	linux-kernel, kernel-janitors

Hello,

> If the bitmap allocations fail then dw_pcie_ep_init_registers() currently
> returns success.  Return -ENOMEM instead.
[...]
> --- a/drivers/pci/controller/dwc/pcie-designware-ep.c
> +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c
> @@ -908,6 +908,7 @@ int dw_pcie_ep_init_registers(struct dw_pcie_ep *ep)
>  	if (ret)
>  		return ret;
>  
> +	ret = -ENOMEM;
>  	if (!ep->ib_window_map) {
>  		ep->ib_window_map = devm_bitmap_zalloc(dev, pci->num_ib_windows,
>  						       GFP_KERNEL);

Nice catch!

This will cover subsequent calls to devm_bitmap_zalloc() and devm_kcalloc().

Reviewed-by: Krzysztof Wilczyński <kw@linux.com>

Thank you!

	Krzysztof

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] PCI: dwc: ep: Return -ENOMEM for allocation failures
  2025-03-05 15:00 [PATCH] PCI: dwc: ep: Return -ENOMEM for allocation failures Dan Carpenter
  2025-03-05 15:53 ` Krzysztof Wilczyński
@ 2025-03-05 16:10 ` Krzysztof Wilczyński
  2025-03-13  6:03 ` Manivannan Sadhasivam
  2 siblings, 0 replies; 4+ messages in thread
From: Krzysztof Wilczyński @ 2025-03-05 16:10 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Manivannan Sadhasivam, Jingoo Han, Lorenzo Pieralisi, Rob Herring,
	Bjorn Helgaas, Vidya Sagar, Frank Li, Niklas Cassel, linux-pci,
	linux-kernel, kernel-janitors

Hello,

> If the bitmap allocations fail then dw_pcie_ep_init_registers() currently
> returns success.  Return -ENOMEM instead.

Applied to controller/dwc, thank you!

	Krzysztof

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] PCI: dwc: ep: Return -ENOMEM for allocation failures
  2025-03-05 15:00 [PATCH] PCI: dwc: ep: Return -ENOMEM for allocation failures Dan Carpenter
  2025-03-05 15:53 ` Krzysztof Wilczyński
  2025-03-05 16:10 ` Krzysztof Wilczyński
@ 2025-03-13  6:03 ` Manivannan Sadhasivam
  2 siblings, 0 replies; 4+ messages in thread
From: Manivannan Sadhasivam @ 2025-03-13  6:03 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Jingoo Han, Lorenzo Pieralisi, Krzysztof Wilczyński,
	Rob Herring, Bjorn Helgaas, Vidya Sagar, Frank Li, Niklas Cassel,
	linux-pci, linux-kernel, kernel-janitors

On Wed, Mar 05, 2025 at 06:00:07PM +0300, Dan Carpenter wrote:
> If the bitmap allocations fail then dw_pcie_ep_init_registers() currently
> returns success.  Return -ENOMEM instead.
> 
> Fixes: 869bc5253406 ("PCI: dwc: ep: Fix DBI access failure for drivers requiring refclk from host")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>

Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>

- Mani

> ---
>  drivers/pci/controller/dwc/pcie-designware-ep.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c
> index 20f2436c7091..1b873d486b2d 100644
> --- a/drivers/pci/controller/dwc/pcie-designware-ep.c
> +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c
> @@ -908,6 +908,7 @@ int dw_pcie_ep_init_registers(struct dw_pcie_ep *ep)
>  	if (ret)
>  		return ret;
>  
> +	ret = -ENOMEM;
>  	if (!ep->ib_window_map) {
>  		ep->ib_window_map = devm_bitmap_zalloc(dev, pci->num_ib_windows,
>  						       GFP_KERNEL);
> -- 
> 2.47.2
> 

-- 
மணிவண்ணன் சதாசிவம்

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-03-13  6:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-05 15:00 [PATCH] PCI: dwc: ep: Return -ENOMEM for allocation failures Dan Carpenter
2025-03-05 15:53 ` Krzysztof Wilczyński
2025-03-05 16:10 ` Krzysztof Wilczyński
2025-03-13  6:03 ` Manivannan Sadhasivam

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox