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@xxxxxxxxxxxx> > > Signed-off-by: Keith Busch <keith.busch@xxxxxxxxx> > > 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. :)