diff options
author | Alan <gnomes@lxorguk.ukuu.org.uk> | 2016-02-19 07:56:57 -0500 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2016-03-03 16:45:53 -0500 |
commit | 5e422cffe822874cefc1657cd287c8647b2782dd (patch) | |
tree | 9c034345eb0b5830cb43e64e6a6fab762a9a50c1 /drivers/lightnvm/core.c | |
parent | 5a7058450cbc8702f976d1f444974485c70cb525 (diff) |
lightnvm: fix up nonsensical configure overrun checking
Instead of checking a constant 0 actually check the space available. Even
better remember to allow for the header and also check the right amount of
space is needed.
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Matias Bjørling <m@bjorling.me>
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'drivers/lightnvm/core.c')
-rw-r--r-- | drivers/lightnvm/core.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c index 33224cb91c5b..782ac5d60a49 100644 --- a/drivers/lightnvm/core.c +++ b/drivers/lightnvm/core.c | |||
@@ -870,20 +870,19 @@ static int nvm_configure_by_str_event(const char *val, | |||
870 | 870 | ||
871 | static int nvm_configure_get(char *buf, const struct kernel_param *kp) | 871 | static int nvm_configure_get(char *buf, const struct kernel_param *kp) |
872 | { | 872 | { |
873 | int sz = 0; | 873 | int sz; |
874 | char *buf_start = buf; | ||
875 | struct nvm_dev *dev; | 874 | struct nvm_dev *dev; |
876 | 875 | ||
877 | buf += sprintf(buf, "available devices:\n"); | 876 | sz = sprintf(buf, "available devices:\n"); |
878 | down_write(&nvm_lock); | 877 | down_write(&nvm_lock); |
879 | list_for_each_entry(dev, &nvm_devices, devices) { | 878 | list_for_each_entry(dev, &nvm_devices, devices) { |
880 | if (sz > 4095 - DISK_NAME_LEN) | 879 | if (sz > 4095 - DISK_NAME_LEN - 2) |
881 | break; | 880 | break; |
882 | buf += sprintf(buf, " %32s\n", dev->name); | 881 | sz += sprintf(buf + sz, " %32s\n", dev->name); |
883 | } | 882 | } |
884 | up_write(&nvm_lock); | 883 | up_write(&nvm_lock); |
885 | 884 | ||
886 | return buf - buf_start - 1; | 885 | return sz; |
887 | } | 886 | } |
888 | 887 | ||
889 | static const struct kernel_param_ops nvm_configure_by_str_event_param_ops = { | 888 | static const struct kernel_param_ops nvm_configure_by_str_event_param_ops = { |