* [PATCH] PCI/P2PDMA: Fix freeing dev_pagemap on error
@ 2018-10-12 15:52 Keith Busch
2018-10-12 15:56 ` Keith Busch
2018-10-12 15:58 ` Logan Gunthorpe
0 siblings, 2 replies; 4+ messages in thread
From: Keith Busch @ 2018-10-12 15:52 UTC (permalink / raw)
To: linux-pci, Bjorn Helgaas; +Cc: Keith Busch, Logan Gunthorpe
The devres_free() API is only to be used after the resource has been
unlinked from the device tracking it. Calling this functino directly will
hit a kernel BUG_ON. This patch fixes this to use the managed resource
release function, devm_kfree().
Fixes: 1380472e7b855 ("PCI/P2PDMA: Support peer-to-peer memory")
Cc: Logan Gunthorpe <logang@deltatee.com>
Signed-off-by: Keith Busch <keith.busch@intel.com>
---
drivers/pci/p2pdma.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c
index da66c7e31730..9c56a10eff15 100644
--- a/drivers/pci/p2pdma.c
+++ b/drivers/pci/p2pdma.c
@@ -222,7 +222,7 @@ int pci_p2pdma_add_resource(struct pci_dev *pdev, int bar, size_t size,
return 0;
pgmap_free:
- devres_free(pgmap);
+ devm_kfree(&pci->dev, pgmap);
return error;
}
EXPORT_SYMBOL_GPL(pci_p2pdma_add_resource);
--
2.14.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] PCI/P2PDMA: Fix freeing dev_pagemap on error
2018-10-12 15:52 [PATCH] PCI/P2PDMA: Fix freeing dev_pagemap on error Keith Busch
@ 2018-10-12 15:56 ` Keith Busch
2018-10-12 15:58 ` Logan Gunthorpe
1 sibling, 0 replies; 4+ messages in thread
From: Keith Busch @ 2018-10-12 15:56 UTC (permalink / raw)
To: linux-pci, Bjorn Helgaas; +Cc: Logan Gunthorpe
On Fri, Oct 12, 2018 at 09:52:19AM -0600, Keith Busch wrote:
> The devres_free() API is only to be used after the resource has been
> unlinked from the device tracking it. Calling this functino directly will
> hit a kernel BUG_ON. This patch fixes this to use the managed resource
> release function, devm_kfree().
>
> Fixes: 1380472e7b855 ("PCI/P2PDMA: Support peer-to-peer memory")
> Cc: Logan Gunthorpe <logang@deltatee.com>
> Signed-off-by: Keith Busch <keith.busch@intel.com>
> ---
> drivers/pci/p2pdma.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c
> index da66c7e31730..9c56a10eff15 100644
> --- a/drivers/pci/p2pdma.c
> +++ b/drivers/pci/p2pdma.c
> @@ -222,7 +222,7 @@ int pci_p2pdma_add_resource(struct pci_dev *pdev, int bar, size_t size,
> return 0;
>
> pgmap_free:
> - devres_free(pgmap);
> + devm_kfree(&pci->dev, pgmap);
^^^
That should be 'pdev', not 'pci'. I need to slow down the workflow, I'm
pointing send-email to the wrong patches again...
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] PCI/P2PDMA: Fix freeing dev_pagemap on error
2018-10-12 15:52 [PATCH] PCI/P2PDMA: Fix freeing dev_pagemap on error Keith Busch
2018-10-12 15:56 ` Keith Busch
@ 2018-10-12 15:58 ` Logan Gunthorpe
2018-10-12 16:21 ` Keith Busch
1 sibling, 1 reply; 4+ messages in thread
From: Logan Gunthorpe @ 2018-10-12 15:58 UTC (permalink / raw)
To: Keith Busch, linux-pci, Bjorn Helgaas
On 2018-10-12 9:52 a.m., Keith Busch wrote:
> The devres_free() API is only to be used after the resource has been
> unlinked from the device tracking it. Calling this functino directly will
> hit a kernel BUG_ON. This patch fixes this to use the managed resource
> release function, devm_kfree().
>
> Fixes: 1380472e7b855 ("PCI/P2PDMA: Support peer-to-peer memory")
> Cc: Logan Gunthorpe <logang@deltatee.com>
> Signed-off-by: Keith Busch <keith.busch@intel.com>
Oops, yes, nice catch! Thanks!
Reviewed-by: Logan Gunthorpe <logang@deltatee.com>
> ---
> drivers/pci/p2pdma.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c
> index da66c7e31730..9c56a10eff15 100644
> --- a/drivers/pci/p2pdma.c
> +++ b/drivers/pci/p2pdma.c
> @@ -222,7 +222,7 @@ int pci_p2pdma_add_resource(struct pci_dev *pdev, int bar, size_t size,
> return 0;
>
> pgmap_free:
> - devres_free(pgmap);
> + devm_kfree(&pci->dev, pgmap);
> return error;
> }
> EXPORT_SYMBOL_GPL(pci_p2pdma_add_resource);
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] PCI/P2PDMA: Fix freeing dev_pagemap on error
2018-10-12 15:58 ` Logan Gunthorpe
@ 2018-10-12 16:21 ` Keith Busch
0 siblings, 0 replies; 4+ messages in thread
From: Keith Busch @ 2018-10-12 16:21 UTC (permalink / raw)
To: Logan Gunthorpe; +Cc: linux-pci, Bjorn Helgaas
On Fri, Oct 12, 2018 at 09:58:14AM -0600, Logan Gunthorpe wrote:
> On 2018-10-12 9:52 a.m., Keith Busch wrote:
> > The devres_free() API is only to be used after the resource has been
> > unlinked from the device tracking it. Calling this functino directly will
> > hit a kernel BUG_ON. This patch fixes this to use the managed resource
> > release function, devm_kfree().
> >
> > Fixes: 1380472e7b855 ("PCI/P2PDMA: Support peer-to-peer memory")
> > Cc: Logan Gunthorpe <logang@deltatee.com>
> > Signed-off-by: Keith Busch <keith.busch@intel.com>
>
> Oops, yes, nice catch! Thanks!
Yeah, I hit the bug after an nvme controller reset. The nvme driver
tries to add its CMB memory a second time, and it's correctly detected
as an error by devm_memremap_pages(), but I'm also thinking nvme should
have known better too.
Anyway, this patch (its v2, really) is the simple error handling fix,
but there will be a follow up nvme patch to avoid the error in the first
place. :)
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-10-12 16:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-12 15:52 [PATCH] PCI/P2PDMA: Fix freeing dev_pagemap on error Keith Busch
2018-10-12 15:56 ` Keith Busch
2018-10-12 15:58 ` Logan Gunthorpe
2018-10-12 16:21 ` Keith Busch
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).