summaryrefslogtreecommitdiff
path: root/drivers/lightnvm/core.c
diff options
context:
space:
mode:
authorMatias Bjørling <matias@cnexlabs.com>2017-02-15 16:25:32 +0100
committerJens Axboe <axboe@fb.com>2017-02-15 08:27:19 -0700
commit0e5ffd1cb5f7ce19f23cc829d5dc3ebb1491570f (patch)
treea1e8f48934b75dd5e7e0cd9f6c292c82f24be26b /drivers/lightnvm/core.c
parent0222967ba05a0a0f845f7dd54fb3da82afae024d (diff)
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 <matias@cnexlabs.com> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'drivers/lightnvm/core.c')
-rw-r--r--drivers/lightnvm/core.c4
1 files changed, 2 insertions, 2 deletions
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;
}