|
@@ -70,6 +70,9 @@ static ssize_t bin_attr_nvmem_read(struct file *filp, struct kobject *kobj,
|
|
|
if (pos >= nvmem->size)
|
|
|
return 0;
|
|
|
|
|
|
+ if (count < nvmem->word_size)
|
|
|
+ return -EINVAL;
|
|
|
+
|
|
|
if (pos + count > nvmem->size)
|
|
|
count = nvmem->size - pos;
|
|
|
|
|
@@ -95,6 +98,9 @@ static ssize_t bin_attr_nvmem_write(struct file *filp, struct kobject *kobj,
|
|
|
if (pos >= nvmem->size)
|
|
|
return 0;
|
|
|
|
|
|
+ if (count < nvmem->word_size)
|
|
|
+ return -EINVAL;
|
|
|
+
|
|
|
if (pos + count > nvmem->size)
|
|
|
count = nvmem->size - pos;
|
|
|
|