[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241023-imx-ele-ocotp-fixes-v1-1-4adc00ce288f@pengutronix.de>
Date: Wed, 23 Oct 2024 10:12:28 +0200
From: Sascha Hauer <s.hauer@...gutronix.de>
To: Srinivas Kandagatla <srinivas.kandagatla@...aro.org>,
Shawn Guo <shawnguo@...nel.org>,
Pengutronix Kernel Team <kernel@...gutronix.de>,
Fabio Estevam <festevam@...il.com>
Cc: imx@...ts.linux.dev, linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org, Sascha Hauer <s.hauer@...gutronix.de>
Subject: [PATCH 1/4] nvmem: imx-ocotp-ele: simplify read beyond device
check
Do the read beyond device check on function entry in bytes instead of
32bit words which is easier to follow.
Signed-off-by: Sascha Hauer <s.hauer@...gutronix.de>
---
drivers/nvmem/imx-ocotp-ele.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/nvmem/imx-ocotp-ele.c b/drivers/nvmem/imx-ocotp-ele.c
index 1ba4944976987..2e186b7d3b040 100644
--- a/drivers/nvmem/imx-ocotp-ele.c
+++ b/drivers/nvmem/imx-ocotp-ele.c
@@ -72,13 +72,13 @@ static int imx_ocotp_reg_read(void *context, unsigned int offset, void *val, siz
void *p;
int i;
+ if (offset + bytes > priv->data->size)
+ bytes = priv->data->size - offset;
+
index = offset;
num_bytes = round_up(bytes, 4);
count = num_bytes >> 2;
- if (count > ((priv->data->size >> 2) - index))
- count = (priv->data->size >> 2) - index;
-
p = kzalloc(num_bytes, GFP_KERNEL);
if (!p)
return -ENOMEM;
--
2.39.5
Powered by blists - more mailing lists