Skip to content

Commit 5887738

Browse files
t-8chgregkh
authored andcommitted
nvmem: core: drop unnecessary range checks in sysfs callbacks
The same checks have already been done in sysfs_kf_bin_write() and sysfs_kf_bin_read() just before the callbacks are invoked. Signed-off-by: Thomas Weißschuh <[email protected]> Signed-off-by: Srinivas Kandagatla <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 6839fed commit 5887738

File tree

1 file changed

+0
-14
lines changed

1 file changed

+0
-14
lines changed

drivers/nvmem/core.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -203,19 +203,12 @@ static ssize_t bin_attr_nvmem_read(struct file *filp, struct kobject *kobj,
203203
dev = kobj_to_dev(kobj);
204204
nvmem = to_nvmem_device(dev);
205205

206-
/* Stop the user from reading */
207-
if (pos >= nvmem->size)
208-
return 0;
209-
210206
if (!IS_ALIGNED(pos, nvmem->stride))
211207
return -EINVAL;
212208

213209
if (count < nvmem->word_size)
214210
return -EINVAL;
215211

216-
if (pos + count > nvmem->size)
217-
count = nvmem->size - pos;
218-
219212
count = round_down(count, nvmem->word_size);
220213

221214
if (!nvmem->reg_read)
@@ -243,19 +236,12 @@ static ssize_t bin_attr_nvmem_write(struct file *filp, struct kobject *kobj,
243236
dev = kobj_to_dev(kobj);
244237
nvmem = to_nvmem_device(dev);
245238

246-
/* Stop the user from writing */
247-
if (pos >= nvmem->size)
248-
return -EFBIG;
249-
250239
if (!IS_ALIGNED(pos, nvmem->stride))
251240
return -EINVAL;
252241

253242
if (count < nvmem->word_size)
254243
return -EINVAL;
255244

256-
if (pos + count > nvmem->size)
257-
count = nvmem->size - pos;
258-
259245
count = round_down(count, nvmem->word_size);
260246

261247
if (!nvmem->reg_write)

0 commit comments

Comments
 (0)