MLK-20893: imx: in_le32 out_le32 preprocessor casting issue with addresses involving...
authorUtkarsh Gupta <utkarsh.gupta@nxp.com>
Mon, 25 Feb 2019 18:00:23 +0000 (12:00 -0600)
committerYe Li <ye.li@nxp.com>
Wed, 28 Apr 2021 20:48:55 +0000 (13:48 -0700)
commit57f7d4e70f21bf71d0d875c154561795148a3a9d
tree492f9a3fdb5af8ba0ace7d579f8c2f93553f9da7
parent2472b4bac96a8cd3ed5e60346c0a597dc178519e
MLK-20893: imx: in_le32 out_le32 preprocessor casting issue with addresses involving math

The sec_in32 preprocessor is defined as follows in include/fsl_sec.h file:
When address "a" is calculated using math for ex: addition of base address and an offset, then casting is applied only to the first address which in this example is base address.

caam_ccbvid_reg = sec_in32(CONFIG_SYS_FSL_SEC_ADDR + CAAM_CCBVID_OFFSET)
resolves to:
caam_ccbvid_reg = in_le32((ulong *)(ulong)CONFIG_SYS_FSL_SEC_ADDR + CAAM_CCBVID_OFFSET)
instead it should resolve to:
caam_ccbvid_reg = in_le32((ulong *)(ulong)(CONFIG_SYS_FSL_SEC_ADDR + CAAM_CCBVID_OFFSET))

Thus add parenthesis around the address "a" so that however the address is calculated, the casting is applied to the final calculated address.

Bug introduced by commit 79e90af14af3 ("MLK-18044-2: crypto: caam: Fix build warnings pointer casting").

Signed-off-by: Utkarsh Gupta <utkarsh.gupta@nxp.com>
Reviewed-by: Horia Geanta <horia.geanta@nxp.com>
Reviewed-by: Ye Li <ye.li@nxp.com>
(cherry picked from commit 5d10d1cab052f8af4fd00640e09642aa0a596922)
(cherry picked from commit 0dfa4efe7ce53042c48fb21ba1060045238b5ccb)
include/fsl_sec.h