mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-03-18 05:04:04 +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
1 changed files with 2 additions and 2 deletions
|
@ -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…
Add table
Reference in a new issue