From: Matias Bjørling Date: Wed, 15 Feb 2017 15:25:32 +0000 (+0100) Subject: lightnvm: fix off-by-one error on target initialization X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=0e5ffd1cb5f7ce19f23cc829d5dc3ebb1491570f;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git lightnvm: fix off-by-one error on target initialization If one specifies the end lun id to be the absolute number of luns, without taking zero indexing into account, the lightnvm core will pass the off-by-one end lun id to target creation, which then panics during nvm_ioctl_dev_create. Signed-off-by: Matias Bjørling Signed-off-by: Jens Axboe --- diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c index 9bfe0352d093..6ce76c0a75e1 100644 --- a/drivers/lightnvm/core.c +++ b/drivers/lightnvm/core.c @@ -1102,9 +1102,9 @@ static int __nvm_configure_create(struct nvm_ioctl_create *create) } s = &create->conf.s; - if (s->lun_begin > s->lun_end || s->lun_end > dev->geo.nr_luns) { + if (s->lun_begin > s->lun_end || s->lun_end >= dev->geo.nr_luns) { pr_err("nvm: lun out of bound (%u:%u > %u)\n", - s->lun_begin, s->lun_end, dev->geo.nr_luns); + s->lun_begin, s->lun_end, dev->geo.nr_luns - 1); return -EINVAL; }