1 From 588773802c386d38f9c4e91acd47369e89d95a30 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= <linux@weissschuh.net>
3 Date: Fri, 5 Jul 2024 08:48:48 +0100
4 Subject: [PATCH] nvmem: core: drop unnecessary range checks in sysfs callbacks
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 The same checks have already been done in sysfs_kf_bin_write() and
10 sysfs_kf_bin_read() just before the callbacks are invoked.
12 Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
13 Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
14 Link: https://lore.kernel.org/r/20240705074852.423202-12-srinivas.kandagatla@linaro.org
15 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
17 drivers/nvmem/core.c | 14 --------------
18 1 file changed, 14 deletions(-)
20 --- a/drivers/nvmem/core.c
21 +++ b/drivers/nvmem/core.c
22 @@ -204,19 +204,12 @@ static ssize_t bin_attr_nvmem_read(struc
23 dev = kobj_to_dev(kobj);
24 nvmem = to_nvmem_device(dev);
26 - /* Stop the user from reading */
27 - if (pos >= nvmem->size)
30 if (!IS_ALIGNED(pos, nvmem->stride))
33 if (count < nvmem->word_size)
36 - if (pos + count > nvmem->size)
37 - count = nvmem->size - pos;
39 count = round_down(count, nvmem->word_size);
42 @@ -244,19 +237,12 @@ static ssize_t bin_attr_nvmem_write(stru
43 dev = kobj_to_dev(kobj);
44 nvmem = to_nvmem_device(dev);
46 - /* Stop the user from writing */
47 - if (pos >= nvmem->size)
50 if (!IS_ALIGNED(pos, nvmem->stride))
53 if (count < nvmem->word_size)
56 - if (pos + count > nvmem->size)
57 - count = nvmem->size - pos;
59 count = round_down(count, nvmem->word_size);
61 if (!nvmem->reg_write)