History

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.

Chris Ye committed 4 years ago

Commit ef910201 parent a111daf1 file · +2 −2Browse files

Unified · Split

drivers/nvdimm/bus.c+2−2
@@ -176,8 +176,8 @@ static int nvdimm_clear_badblocks_region(struct device *dev, void *data) · 175 unmodified lines
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;