Skip to contentSkip to conversation

soc: fsl: guts: fix return value check in fsl_guts_init()

PATCH Applied Yang Yingliang 3 participants 5 messages Jun 28, 2022 – Jul 5, 2022 Freescale SoC drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 soc: fsl: guts: fix return value check in fsl_guts_init()

In case of error, of_iomap() returns NULL pointer not ERR_PTR(). The IS_ERR() test in the return value check should be replaced with NULL test and return -ENOMEM as error value.

Fixes ab4988d6a393 ("soc: fsl: guts: embed fsl_guts_get_svr() in probe()")
---
 drivers/soc/fsl/guts.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/soc/fsl/guts.c +2 -2
index 27035de062f8..8038c599ad83 100644
@@ -195,9 +195,9 @@ static int __init fsl_guts_init(void)
 	soc_data = match->data;
 
 	regs = of_iomap(np, 0);
-	if (IS_ERR(regs)) {
+	if (!regs) {
 		of_node_put(np);
-		return PTR_ERR(regs);
+		return -ENOMEM;
 	}
 
 	little_endian = of_property_read_bool(np, "little-endian");
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/2 soc: fsl: guts: check return value after calling of_iomap() in fsl_guts_get_soc_uid()

of_iomap() may return NULL, so we need check the return value.

Fixes 786dde1e59d7 ("soc: fsl: guts: add serial_number support")
---
 drivers/soc/fsl/guts.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/soc/fsl/guts.c +4 -0
index 8038c599ad83..6bf3e6a980ff 100644
@@ -126,6 +126,10 @@ static u64 fsl_guts_get_soc_uid(const char *compat, unsigned int offset)
 		return 0;
 
 	sfp_base = of_iomap(np, 0);
+	if (!sfp_base) {
+		of_node_put(np);
+		return 0;
+	}
 
 	uid = ioread32(sfp_base + offset);
 	uid <<= 32;
Signature · 1 line
2.25.1
Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH -next 2/2] soc: fsl: guts: check return value after calling of_iomap() in fsl_guts_get_soc_uid()

Am 2022-06-28 16:02, schrieb Yang Yingliang:

Quoted 5 lines

of_iomap() may return NULL, so we need check the return value.

Fixes 786dde1e59d7 ("soc: fsl: guts: add serial_number support")
Reviewed-by on v1 1/2
#3 lore raw
In reply to Yang Yingliang

Am 2022-06-28 16:02, schrieb Yang Yingliang:

Quoted 7 lines

In case of error, of_iomap() returns NULL pointer not ERR_PTR(). The IS_ERR() test in the return value check should be replaced with NULL test and return -ENOMEM as error value.

Fixes ab4988d6a393 ("soc: fsl: guts: embed fsl_guts_get_svr() in probe()")

Thanks!