* [PATCH] nvdimm: Fix badblocks clear off-by-one error
@ 2022-06-01 0:09 Dan Williams
2022-06-01 20:13 ` Verma, Vishal L
0 siblings, 1 reply; 2+ messages in thread
From: Dan Williams @ 2022-06-01 0:09 UTC (permalink / raw)
To: nvdimm; +Cc: stable, Chris Ye
From: Chris Ye <chris.ye@intel.com>
nvdimm_clear_badblocks_region() validates badblock clearing requests
against the span of the region, however it compares the inclusive
badblock request range to the exclusive region range. Fix up the
off-by-one error.
Fixes: 23f498448362 ("libnvdimm: rework region badblocks clearing")
Cc: <stable@vger.kernel.org>
Signed-off-by: Chris Ye <chris.ye@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
drivers/nvdimm/bus.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
index 7b0d1443217a..5db16857b80e 100644
--- a/drivers/nvdimm/bus.c
+++ b/drivers/nvdimm/bus.c
@@ -182,8 +182,8 @@ static int nvdimm_clear_badblocks_region(struct device *dev, void *data)
ndr_end = nd_region->ndr_start + nd_region->ndr_size - 1;
/* make sure we are in the region */
- if (ctx->phys < nd_region->ndr_start
- || (ctx->phys + ctx->cleared) > ndr_end)
+ if (ctx->phys < nd_region->ndr_start ||
+ (ctx->phys + ctx->cleared - 1) > ndr_end)
return 0;
sector = (ctx->phys - nd_region->ndr_start) / 512;
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] nvdimm: Fix badblocks clear off-by-one error
2022-06-01 0:09 [PATCH] nvdimm: Fix badblocks clear off-by-one error Dan Williams
@ 2022-06-01 20:13 ` Verma, Vishal L
0 siblings, 0 replies; 2+ messages in thread
From: Verma, Vishal L @ 2022-06-01 20:13 UTC (permalink / raw)
To: Williams, Dan J, nvdimm; +Cc: stable, Ye, Chris
On Tue, 2022-05-31 at 17:09 -0700, Dan Williams wrote:
> From: Chris Ye <chris.ye@intel.com>
>
> nvdimm_clear_badblocks_region() validates badblock clearing requests
> against the span of the region, however it compares the inclusive
> badblock request range to the exclusive region range. Fix up the
> off-by-one error.
>
> Fixes: 23f498448362 ("libnvdimm: rework region badblocks clearing")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Chris Ye <chris.ye@intel.com>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> ---
> drivers/nvdimm/bus.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
Good find! Looks good to me,
Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>
>
> diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
> index 7b0d1443217a..5db16857b80e 100644
> --- a/drivers/nvdimm/bus.c
> +++ b/drivers/nvdimm/bus.c
> @@ -182,8 +182,8 @@ static int nvdimm_clear_badblocks_region(struct
> device *dev, void *data)
> ndr_end = nd_region->ndr_start + nd_region->ndr_size - 1;
>
> /* make sure we are in the region */
> - if (ctx->phys < nd_region->ndr_start
> - || (ctx->phys + ctx->cleared) > ndr_end)
> + if (ctx->phys < nd_region->ndr_start ||
> + (ctx->phys + ctx->cleared - 1) > ndr_end)
> return 0;
>
> sector = (ctx->phys - nd_region->ndr_start) / 512;
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-06-01 20:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-01 0:09 [PATCH] nvdimm: Fix badblocks clear off-by-one error Dan Williams
2022-06-01 20:13 ` Verma, Vishal L
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.