Skip to content

Commit ef91020

Browse files
yechun1djbw
authored andcommitted
nvdimm: Fix badblocks clear off-by-one error
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: 23f4984 ("libnvdimm: rework region badblocks clearing") Cc: <[email protected]> Signed-off-by: Chris Ye <[email protected]> Reviewed-by: Vishal Verma <[email protected]> Link: https://lore.kernel.org/r/165404219489.2445897.9792886413715690399.stgit@dwillia2-xfh Signed-off-by: Dan Williams <[email protected]>
1 parent a111daf commit ef91020

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/nvdimm/bus.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ static int nvdimm_clear_badblocks_region(struct device *dev, void *data)
176176
ndr_end = nd_region->ndr_start + nd_region->ndr_size - 1;
177177

178178
/* make sure we are in the region */
179-
if (ctx->phys < nd_region->ndr_start
180-
|| (ctx->phys + ctx->cleared) > ndr_end)
179+
if (ctx->phys < nd_region->ndr_start ||
180+
(ctx->phys + ctx->cleared - 1) > ndr_end)
181181
return 0;
182182

183183
sector = (ctx->phys - nd_region->ndr_start) / 512;

0 commit comments

Comments
 (0)