diff options
author | Guy Shapiro <guy.shapiro@mobi-wize.com> | 2017-09-11 05:00:11 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-09-18 10:12:26 -0400 |
commit | 38b0774c0598c7a54b8499d18c2b764c35dc94ab (patch) | |
tree | 75072e17f1b771355a271c3e0289801da5b5e773 | |
parent | 93dc1774d2a4c7a298d5cdf78cc8acdcb7b1428d (diff) |
nvmem: core: return EFBIG on out-of-range write
When writing data that exceeds the nvmem size to a nvmem sysfs file
using the sh redirection operator >, the shell hangs, trying to
write the out-of-range bytes endlessly.
Fix the problem by returning EFBIG described in man 2 write.
Similar change was done for binary sysfs files on commit
0936896056365349afa867c16e9f9100a6707cbf
Signed-off-by: Guy Shapiro <guy.shapiro@mobi-wize.com>
Cc: linux-api@vger.kernel.org
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/nvmem/core.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index de54c7f5048a..3866117bc285 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c | |||
@@ -135,7 +135,7 @@ static ssize_t bin_attr_nvmem_write(struct file *filp, struct kobject *kobj, | |||
135 | 135 | ||
136 | /* Stop the user from writing */ | 136 | /* Stop the user from writing */ |
137 | if (pos >= nvmem->size) | 137 | if (pos >= nvmem->size) |
138 | return 0; | 138 | return -EFBIG; |
139 | 139 | ||
140 | if (count < nvmem->word_size) | 140 | if (count < nvmem->word_size) |
141 | return -EINVAL; | 141 | return -EINVAL; |