Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Thomas Weißschuh and committed by
Greg Kroah-Hartman
58877380 6839fed0

-14
-14
drivers/nvmem/core.c
··· 203 203 dev = kobj_to_dev(kobj); 204 204 nvmem = to_nvmem_device(dev); 205 205 206 - /* Stop the user from reading */ 207 - if (pos >= nvmem->size) 208 - return 0; 209 - 210 206 if (!IS_ALIGNED(pos, nvmem->stride)) 211 207 return -EINVAL; 212 208 213 209 if (count < nvmem->word_size) 214 210 return -EINVAL; 215 - 216 - if (pos + count > nvmem->size) 217 - count = nvmem->size - pos; 218 211 219 212 count = round_down(count, nvmem->word_size); 220 213 ··· 236 243 dev = kobj_to_dev(kobj); 237 244 nvmem = to_nvmem_device(dev); 238 245 239 - /* Stop the user from writing */ 240 - if (pos >= nvmem->size) 241 - return -EFBIG; 242 - 243 246 if (!IS_ALIGNED(pos, nvmem->stride)) 244 247 return -EINVAL; 245 248 246 249 if (count < nvmem->word_size) 247 250 return -EINVAL; 248 - 249 - if (pos + count > nvmem->size) 250 - count = nvmem->size - pos; 251 251 252 252 count = round_down(count, nvmem->word_size); 253 253