Skip to content

Commit 343aa1e

Browse files
saschahauergregkh
authored andcommitted
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: 22e9e6f ("nvmem: imx: support i.MX93 OCOTP") Signed-off-by: Sascha Hauer <[email protected]> Cc: stable <[email protected]> Reviewed-by: Peng Fan <[email protected]> Signed-off-by: Srinivas Kandagatla <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 5bd97a5 commit 343aa1e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/nvmem/imx-ocotp-ele.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ static int imx_ocotp_reg_read(void *context, unsigned int offset, void *val, siz
7272
void *p;
7373
int i;
7474

75+
if (offset + bytes > priv->data->size)
76+
bytes = priv->data->size - offset;
77+
7578
index = offset;
7679
num_bytes = round_up(bytes, 4);
7780
count = num_bytes >> 2;
7881

79-
if (count > ((priv->data->size >> 2) - index))
80-
count = (priv->data->size >> 2) - index;
81-
8282
p = kzalloc(num_bytes, GFP_KERNEL);
8383
if (!p)
8484
return -ENOMEM;

0 commit comments

Comments
 (0)