mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-14 09:25:12 +00:00
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>
This commit is contained in:
parent
9ffecb1028
commit
7c806883e1
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user