Commit 7c806883 authored by ZhengShunQian's avatar ZhengShunQian Committed by Greg Kroah-Hartman

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: default avatarZhengShunQian <zhengsq@rock-chips.com>
Acked-by: default avatarSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: default avatarSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 9ffecb10
...@@ -67,7 +67,7 @@ static ssize_t bin_attr_nvmem_read(struct file *filp, struct kobject *kobj, ...@@ -67,7 +67,7 @@ static ssize_t bin_attr_nvmem_read(struct file *filp, struct kobject *kobj,
int rc; int rc;
/* Stop the user from reading */ /* Stop the user from reading */
if (pos > nvmem->size) if (pos >= nvmem->size)
return 0; return 0;
if (pos + count > nvmem->size) if (pos + count > nvmem->size)
...@@ -92,7 +92,7 @@ static ssize_t bin_attr_nvmem_write(struct file *filp, struct kobject *kobj, ...@@ -92,7 +92,7 @@ static ssize_t bin_attr_nvmem_write(struct file *filp, struct kobject *kobj,
int rc; int rc;
/* Stop the user from writing */ /* Stop the user from writing */
if (pos > nvmem->size) if (pos >= nvmem->size)
return 0; return 0;
if (pos + count > nvmem->size) if (pos + count > nvmem->size)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment