soc: fsl: guts: check return value after calling of_iomap() in fsl_guts_get_soc_uid()
authorYang Yingliang <yangyingliang@huawei.com>
Tue, 28 Jun 2022 14:02:49 +0000 (22:02 +0800)
committerShawn Guo <shawnguo@kernel.org>
Tue, 5 Jul 2022 00:41:55 +0000 (08:41 +0800)
of_iomap() may return NULL, so we need check the return value.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Reviewed-by: Michael Walle <michael@walle.cc>
Signed-off-by: Shawn Guo <shawnguo@kernel.org>
drivers/soc/fsl/guts.c

index 8038c599ad839b4278da60804faf265c102512d6..6bf3e6a980ffc67c21ed7b62b5b638e37f27454e 100644 (file)
@@ -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;