Skip to content

Commit ca4bdba

Browse files
cdleonardzandrey
authored andcommitted
ARM: imx: Fix boot crash if ocotp is not found
The imx_soc_device_init functions tries to fetch the ocotp regmap in order to soc serial number. If regmap fetch fails then a message is printed but regmap_read is called anyway and the system crashes. Failing to lookup ocotp regmap shouldn't be a fatal boot error so check that the pointer is valid. Only side-effect of ocotp lookup failure now is that serial number will be reported as all-zeros which is acceptable. Cc: [email protected] Fixes: 8267ff8 ("ARM: imx: Add serial number support for i.MX6/7 SoCs") Signed-off-by: Leonard Crestez <[email protected]> Tested-by: Christoph Niedermaier <[email protected]> Signed-off-by: Shawn Guo <[email protected]> (cherry picked from commit 7947e32)
1 parent 0935940 commit ca4bdba

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

arch/arm/mach-imx/cpu.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ struct device * __init imx_soc_device_init(void)
8484
const char *ocotp_compat = NULL;
8585
struct soc_device *soc_dev;
8686
struct device_node *root;
87-
struct regmap *ocotp;
87+
struct regmap *ocotp = NULL;
8888
const char *soc_id;
8989
u64 soc_uid = 0;
9090
u32 val;
@@ -178,7 +178,9 @@ struct device * __init imx_soc_device_init(void)
178178
ocotp = syscon_regmap_lookup_by_compatible(ocotp_compat);
179179
if (IS_ERR(ocotp))
180180
pr_err("%s: failed to find %s regmap!\n", __func__, ocotp_compat);
181+
}
181182

183+
if (!IS_ERR_OR_NULL(ocotp)) {
182184
regmap_read(ocotp, OCOTP_UID_H, &val);
183185
soc_uid = val;
184186
regmap_read(ocotp, OCOTP_UID_L, &val);

0 commit comments

Comments
 (0)