lkml.org 
[lkml]   [2017]   [Feb]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 1/2] lightnvm: fix off-by-one error on target initialization
Date
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>
---
drivers/lightnvm/core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c
index 9bfe035..6ce76c0 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;
}

--
2.9.3
\
 
 \ /
  Last update: 2017-02-15 16:28    [W:0.344 / U:0.184 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site