Thread (9 messages) 9 messages, 4 authors, 2019-12-12

Re: [PATCH 1/2] ARM: imx: Fix boot crash if ocotp is not found

From: Christoph Niedermaier <cniedermaier@dh-electronics.com>
Date: 2019-12-11 10:25:49

From: Leonard Crestez <redacted>
Sent: Tuesday, December 10, 2019 10:49 PM
quoted hunk ↗ jump to hunk
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: stable@vger.kernel.org
Fixes: 8267ff89b713 ("ARM: imx: Add serial number support for i.MX6/7 SoCs")
Signed-off-by: Leonard Crestez <redacted>
---
 arch/arm/mach-imx/cpu.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/arm/mach-imx/cpu.c b/arch/arm/mach-imx/cpu.c
index d70b6fc72b35..484bf6cdb363 100644
--- a/arch/arm/mach-imx/cpu.c
+++ b/arch/arm/mach-imx/cpu.c
@@ -87,11 +87,11 @@ struct device * __init imx_soc_device_init(void)
 {
 	struct soc_device_attribute *soc_dev_attr;
 	const char *ocotp_compat = NULL;
 	struct soc_device *soc_dev;
 	struct device_node *root;
-	struct regmap *ocotp;
+	struct regmap *ocotp = NULL;
 	const char *soc_id;
 	u64 soc_uid = 0;
 	u32 val;
 	int ret;
 
@@ -179,11 +179,13 @@ struct device * __init imx_soc_device_init(void)
 
 	if (ocotp_compat) {
 		ocotp = syscon_regmap_lookup_by_compatible(ocotp_compat);
 		if (IS_ERR(ocotp))
 			pr_err("%s: failed to find %s regmap!\n", __func__, ocotp_compat);
+	}
 
+	if (!IS_ERR_OR_NULL(ocotp)) {
 		if (__mxc_cpu_type == MXC_CPU_IMX7ULP) {
 			regmap_read(ocotp, OCOTP_ULP_UID_4, &val);
 			soc_uid = val & 0xffff;
 			regmap_read(ocotp, OCOTP_ULP_UID_3, &val);
 			soc_uid <<= 16;
Tested-by: Christoph Niedermaier <cniedermaier@dh-electronics.com>

Best regards,
Christoph

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help