nvdimm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH] libnvdimm, pmem: Fix badblocks population for 'raw' namespaces
@ 2018-10-04 23:56 Dan Williams
  2018-10-05  0:19 ` Verma, Vishal L
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Williams @ 2018-10-04 23:56 UTC (permalink / raw)
  To: linux-nvdimm
  Cc: Jacek Zloch, Krzysztof Rusocki, Christoph Hellwig, stable, linux-kernel

The driver is only initializing bb_res in the devm_memremap_pages()
paths, but the raw namespace case is passing an uninitialized bb_res to
nvdimm_badblocks_populate().

Fixes: e8d513483300 ("memremap: change devm_memremap_pages interface...")
Cc: <stable@vger.kernel.org>
Cc: Christoph Hellwig <hch@lst.de>
Reported-by: Jacek Zloch <jacek.zloch@intel.com>
Reported-by: Krzysztof Rusocki <krzysztof.rusocki@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 drivers/nvdimm/pmem.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
index 6071e2942053..2082ae01b9c8 100644
--- a/drivers/nvdimm/pmem.c
+++ b/drivers/nvdimm/pmem.c
@@ -421,9 +421,11 @@ static int pmem_attach_disk(struct device *dev,
 		addr = devm_memremap_pages(dev, &pmem->pgmap);
 		pmem->pfn_flags |= PFN_MAP;
 		memcpy(&bb_res, &pmem->pgmap.res, sizeof(bb_res));
-	} else
+	} else {
 		addr = devm_memremap(dev, pmem->phys_addr,
 				pmem->size, ARCH_MEMREMAP_PMEM);
+		memcpy(&bb_res, &nsio->res, sizeof(bb_res));
+	}
 
 	/*
 	 * At release time the queue must be frozen before

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

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

* Re: [PATCH] libnvdimm, pmem: Fix badblocks population for 'raw' namespaces
  2018-10-04 23:56 [PATCH] libnvdimm, pmem: Fix badblocks population for 'raw' namespaces Dan Williams
@ 2018-10-05  0:19 ` Verma, Vishal L
  0 siblings, 0 replies; 2+ messages in thread
From: Verma, Vishal L @ 2018-10-05  0:19 UTC (permalink / raw)
  To: Williams, Dan J, linux-nvdimm
  Cc: Zloch, Jacek, stable, hch, Rusocki, Krzysztof, linux-kernel


On Thu, 2018-10-04 at 16:56 -0700, Dan Williams wrote:
> The driver is only initializing bb_res in the devm_memremap_pages()
> paths, but the raw namespace case is passing an uninitialized bb_res
> to
> nvdimm_badblocks_populate().
> 
> Fixes: e8d513483300 ("memremap: change devm_memremap_pages
> interface...")
> Cc: <stable@vger.kernel.org>
> Cc: Christoph Hellwig <hch@lst.de>
> Reported-by: Jacek Zloch <jacek.zloch@intel.com>
> Reported-by: Krzysztof Rusocki <krzysztof.rusocki@intel.com>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> ---
>  drivers/nvdimm/pmem.c |    4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
> index 6071e2942053..2082ae01b9c8 100644
> --- a/drivers/nvdimm/pmem.c
> +++ b/drivers/nvdimm/pmem.c
> @@ -421,9 +421,11 @@ static int pmem_attach_disk(struct device *dev,
>  		addr = devm_memremap_pages(dev, &pmem->pgmap);
>  		pmem->pfn_flags |= PFN_MAP;
>  		memcpy(&bb_res, &pmem->pgmap.res, sizeof(bb_res));
> -	} else
> +	} else {
>  		addr = devm_memremap(dev, pmem->phys_addr,
>  				pmem->size, ARCH_MEMREMAP_PMEM);
> +		memcpy(&bb_res, &nsio->res, sizeof(bb_res));
> +	}


Good find!
Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

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

end of thread, other threads:[~2018-10-05  0:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-04 23:56 [PATCH] libnvdimm, pmem: Fix badblocks population for 'raw' namespaces Dan Williams
2018-10-05  0:19 ` Verma, Vishal L

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).