summaryrefslogtreecommitdiffstats
path: root/drivers/nvmem
diff options
context:
space:
mode:
authorZhengShunQian <zhengsq@rock-chips.com>2015-09-30 13:33:56 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-10-04 12:09:43 +0100
commit7c806883e143dc60439e6bdb3589700ebed1efaa (patch)
tree1c0b21a959e88862b3179c2515975ed8e6319f5c /drivers/nvmem
parent9ffecb10283508260936b96022d4ee43a7798b4c (diff)
downloadlinux-stable-7c806883e143dc60439e6bdb3589700ebed1efaa.tar.gz
linux-stable-7c806883e143dc60439e6bdb3589700ebed1efaa.tar.bz2
linux-stable-7c806883e143dc60439e6bdb3589700ebed1efaa.zip
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>
Diffstat (limited to 'drivers/nvmem')
-rw-r--r--drivers/nvmem/core.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index d3c6676b3c0c..f4af8e5fcd94 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -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)