diff mbox series

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

Message ID 20220628140249.1073809-2-yangyingliang@huawei.com (mailing list archive)
State New, archived
Headers show
Series [-next,1/2] soc: fsl: guts: fix return value check in fsl_guts_init() | expand

Commit Message

Yang Yingliang June 28, 2022, 2:02 p.m. UTC
of_iomap() may return NULL, so we need check the return value.

Fixes: 786dde1e59d7 ("soc: fsl: guts: add serial_number support")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/soc/fsl/guts.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Michael Walle June 28, 2022, 2:29 p.m. UTC | #1
Am 2022-06-28 16:02, schrieb Yang Yingliang:
> of_iomap() may return NULL, so we need check the return value.
> 
> Fixes: 786dde1e59d7 ("soc: fsl: guts: add serial_number support")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>

Reviewed-by: Michael Walle <michael@walle.cc>
diff mbox series

Patch

diff --git a/drivers/soc/fsl/guts.c b/drivers/soc/fsl/guts.c
index 8038c599ad83..6bf3e6a980ff 100644
--- a/drivers/soc/fsl/guts.c
+++ b/drivers/soc/fsl/guts.c
@@ -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;