Skip to content

Commit

Permalink
lightnvm: fix off-by-one error on target initialization
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Matias Bjørling authored and Jens Axboe committed Feb 15, 2017
1 parent 0222967 commit 0e5ffd1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/lightnvm/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 0e5ffd1

Please sign in to comment.