linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next 1/2] soc: fsl: guts: fix return value check in fsl_guts_init()
@ 2022-06-28 14:02 Yang Yingliang
  2022-06-28 14:02 ` [PATCH -next 2/2] soc: fsl: guts: check return value after calling of_iomap() in fsl_guts_get_soc_uid() Yang Yingliang
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Yang Yingliang @ 2022-06-28 14:02 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, linuxppc-dev; +Cc: michael, shawnguo, arnd

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()")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/soc/fsl/guts.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/soc/fsl/guts.c b/drivers/soc/fsl/guts.c
index 27035de062f8..8038c599ad83 100644
--- a/drivers/soc/fsl/guts.c
+++ b/drivers/soc/fsl/guts.c
@@ -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");
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH -next 2/2] soc: fsl: guts: check return value after calling of_iomap() in fsl_guts_get_soc_uid()
  2022-06-28 14:02 [PATCH -next 1/2] soc: fsl: guts: fix return value check in fsl_guts_init() Yang Yingliang
@ 2022-06-28 14:02 ` Yang Yingliang
  2022-06-28 14:29   ` Michael Walle
  2022-06-28 14:27 ` [PATCH -next 1/2] soc: fsl: guts: fix return value check in fsl_guts_init() Michael Walle
  2022-07-05  0:42 ` Shawn Guo
  2 siblings, 1 reply; 5+ messages in thread
From: Yang Yingliang @ 2022-06-28 14:02 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, linuxppc-dev; +Cc: michael, shawnguo, arnd

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(+)

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;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH -next 1/2] soc: fsl: guts: fix return value check in fsl_guts_init()
  2022-06-28 14:02 [PATCH -next 1/2] soc: fsl: guts: fix return value check in fsl_guts_init() Yang Yingliang
  2022-06-28 14:02 ` [PATCH -next 2/2] soc: fsl: guts: check return value after calling of_iomap() in fsl_guts_get_soc_uid() Yang Yingliang
@ 2022-06-28 14:27 ` Michael Walle
  2022-07-05  0:42 ` Shawn Guo
  2 siblings, 0 replies; 5+ messages in thread
From: Michael Walle @ 2022-06-28 14:27 UTC (permalink / raw)
  To: Yang Yingliang
  Cc: arnd, shawnguo, linuxppc-dev, linux-kernel, linux-arm-kernel

Am 2022-06-28 16:02, schrieb Yang Yingliang:
> 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()")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>

Thanks!

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH -next 2/2] soc: fsl: guts: check return value after calling of_iomap() in fsl_guts_get_soc_uid()
  2022-06-28 14:02 ` [PATCH -next 2/2] soc: fsl: guts: check return value after calling of_iomap() in fsl_guts_get_soc_uid() Yang Yingliang
@ 2022-06-28 14:29   ` Michael Walle
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Walle @ 2022-06-28 14:29 UTC (permalink / raw)
  To: Yang Yingliang
  Cc: arnd, shawnguo, linuxppc-dev, linux-kernel, linux-arm-kernel

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>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH -next 1/2] soc: fsl: guts: fix return value check in fsl_guts_init()
  2022-06-28 14:02 [PATCH -next 1/2] soc: fsl: guts: fix return value check in fsl_guts_init() Yang Yingliang
  2022-06-28 14:02 ` [PATCH -next 2/2] soc: fsl: guts: check return value after calling of_iomap() in fsl_guts_get_soc_uid() Yang Yingliang
  2022-06-28 14:27 ` [PATCH -next 1/2] soc: fsl: guts: fix return value check in fsl_guts_init() Michael Walle
@ 2022-07-05  0:42 ` Shawn Guo
  2 siblings, 0 replies; 5+ messages in thread
From: Shawn Guo @ 2022-07-05  0:42 UTC (permalink / raw)
  To: Yang Yingliang
  Cc: arnd, michael, linuxppc-dev, linux-kernel, linux-arm-kernel

On Tue, Jun 28, 2022 at 10:02:48PM +0800, Yang Yingliang wrote:
> 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()")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>

Applied both, thanks!

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-07-05  0:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-28 14:02 [PATCH -next 1/2] soc: fsl: guts: fix return value check in fsl_guts_init() Yang Yingliang
2022-06-28 14:02 ` [PATCH -next 2/2] soc: fsl: guts: check return value after calling of_iomap() in fsl_guts_get_soc_uid() Yang Yingliang
2022-06-28 14:29   ` Michael Walle
2022-06-28 14:27 ` [PATCH -next 1/2] soc: fsl: guts: fix return value check in fsl_guts_init() Michael Walle
2022-07-05  0:42 ` Shawn Guo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).