diff options
author | Chris Ye <chris.ye@intel.com> | 2022-05-31 17:09:54 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2022-07-07 17:35:09 +0200 |
commit | 1edcdff8a8a2b40667d2620bec733a3e3bdba5d7 (patch) | |
tree | 1c7ae39c079ba2b502c226430383b540c96037ce | |
parent | 7c6679265082335bca08b954208b385143c0d4de (diff) | |
download | linux-stable-1edcdff8a8a2b40667d2620bec733a3e3bdba5d7.tar.gz linux-stable-1edcdff8a8a2b40667d2620bec733a3e3bdba5d7.tar.bz2 linux-stable-1edcdff8a8a2b40667d2620bec733a3e3bdba5d7.zip |
nvdimm: Fix badblocks clear off-by-one error
commit ef9102004a87cb3f8b26e000a095a261fc0467d3 upstream.
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>
Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>
Link: https://lore.kernel.org/r/165404219489.2445897.9792886413715690399.stgit@dwillia2-xfh
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/nvdimm/bus.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c index 48a070a37ea9..6b38b373ed14 100644 --- a/drivers/nvdimm/bus.c +++ b/drivers/nvdimm/bus.c @@ -196,8 +196,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; |