1
0
Fork 0

nvmem: core: fix the out-of-range leak in read/write()

The position to read/write must be less than max
register size.

Signed-off-by: ZhengShunQian <zhengsq@rock-chips.com>
Acked-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
hifive-unleashed-5.1
ZhengShunQian 2015-09-30 13:33:56 +01:00 committed by Greg Kroah-Hartman
parent 9ffecb1028
commit 7c806883e1
1 changed files with 2 additions and 2 deletions

View File

@ -67,7 +67,7 @@ static ssize_t bin_attr_nvmem_read(struct file *filp, struct kobject *kobj,
int rc;
/* Stop the user from reading */
if (pos > nvmem->size)
if (pos >= nvmem->size)
return 0;
if (pos + count > nvmem->size)
@ -92,7 +92,7 @@ static ssize_t bin_attr_nvmem_write(struct file *filp, struct kobject *kobj,
int rc;
/* Stop the user from writing */
if (pos > nvmem->size)
if (pos >= nvmem->size)
return 0;
if (pos + count > nvmem->size)