mirror of
https://github.com/torvalds/linux.git
synced 2024-11-15 00:21:59 +00:00
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 <linux@weissschuh.net> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Link: https://lore.kernel.org/r/20240705074852.423202-12-srinivas.kandagatla@linaro.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
6839fed062
commit
588773802c
@ -203,19 +203,12 @@ static ssize_t bin_attr_nvmem_read(struct file *filp, struct kobject *kobj,
|
||||
dev = kobj_to_dev(kobj);
|
||||
nvmem = to_nvmem_device(dev);
|
||||
|
||||
/* Stop the user from reading */
|
||||
if (pos >= nvmem->size)
|
||||
return 0;
|
||||
|
||||
if (!IS_ALIGNED(pos, nvmem->stride))
|
||||
return -EINVAL;
|
||||
|
||||
if (count < nvmem->word_size)
|
||||
return -EINVAL;
|
||||
|
||||
if (pos + count > nvmem->size)
|
||||
count = nvmem->size - pos;
|
||||
|
||||
count = round_down(count, nvmem->word_size);
|
||||
|
||||
if (!nvmem->reg_read)
|
||||
@ -243,19 +236,12 @@ static ssize_t bin_attr_nvmem_write(struct file *filp, struct kobject *kobj,
|
||||
dev = kobj_to_dev(kobj);
|
||||
nvmem = to_nvmem_device(dev);
|
||||
|
||||
/* Stop the user from writing */
|
||||
if (pos >= nvmem->size)
|
||||
return -EFBIG;
|
||||
|
||||
if (!IS_ALIGNED(pos, nvmem->stride))
|
||||
return -EINVAL;
|
||||
|
||||
if (count < nvmem->word_size)
|
||||
return -EINVAL;
|
||||
|
||||
if (pos + count > nvmem->size)
|
||||
count = nvmem->size - pos;
|
||||
|
||||
count = round_down(count, nvmem->word_size);
|
||||
|
||||
if (!nvmem->reg_write)
|
||||
|
Loading…
Reference in New Issue
Block a user