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:
Родитель
9ffecb1028
Коммит
7c806883e1
|
@ -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,
|
||||||
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)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче