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.
Unified · Split
| @@ -176,8 +176,8 @@ static int nvdimm_clear_badblocks_region(struct device *dev, void *data) · 175 unmodified lines | |||
| 176 | ndr_end = nd_region->ndr_start + nd_region->ndr_size - 1; | 176 | ndr_end = nd_region->ndr_start + nd_region->ndr_size - 1; |
| 177 | 177 | ||
| 178 | /* make sure we are in the region */ | 178 | /* make sure we are in the region */ |
| 179 | if (ctx->phys < nd_region->ndr_start | 179 | if (ctx->phys < nd_region->ndr_start || |
| 180 | || (ctx->phys + ctx->cleared) > ndr_end) | 180 | (ctx->phys + ctx->cleared - 1) > ndr_end) |
| 181 | return 0; | 181 | return 0; |
| 182 | 182 | ||
| 183 | sector = (ctx->phys - nd_region->ndr_start) / 512; | 183 | sector = (ctx->phys - nd_region->ndr_start) / 512; |