mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-01 10:42:11 +00:00
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.
Fixes: 22e9e6fcfb
("nvmem: imx: support i.MX93 OCOTP")
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Cc: stable <stable@kernel.org>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
This commit is contained in:
parent
40384c840e
commit
e09f08213a
@ -72,13 +72,13 @@ static int imx_ocotp_reg_read(void *context, unsigned int offset, void *val, siz
|
|||||||
void *p;
|
void *p;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if (offset + bytes > priv->data->size)
|
||||||
|
bytes = priv->data->size - offset;
|
||||||
|
|
||||||
index = offset;
|
index = offset;
|
||||||
num_bytes = round_up(bytes, 4);
|
num_bytes = round_up(bytes, 4);
|
||||||
count = num_bytes >> 2;
|
count = num_bytes >> 2;
|
||||||
|
|
||||||
if (count > ((priv->data->size >> 2) - index))
|
|
||||||
count = (priv->data->size >> 2) - index;
|
|
||||||
|
|
||||||
p = kzalloc(num_bytes, GFP_KERNEL);
|
p = kzalloc(num_bytes, GFP_KERNEL);
|
||||||
if (!p)
|
if (!p)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
Loading…
Reference in New Issue
Block a user