Skip to contentSkip to conversation

drm/rcar-du: Fix return value check in rcar_du_cmm_init()

PATCH In review Wei Yongjun 3 participants 3 messages Apr 28, 2020

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/rcar-du: Fix return value check in rcar_du_cmm_init()

In case of error, the function of_parse_phandle()/of_find_device_by_node() returns NULL pointer not ERR_PTR(). The IS_ERR() test in the return value check should be replaced with NULL test

Fixes 8de707aeb452 ("drm: rcar-du: kms: Initialize CMM instances")
---
 drivers/gpu/drm/rcar-du/rcar_du_kms.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/rcar-du/rcar_du_kms.c +4 -4
index 482329102f19..0da711d9b2f8 100644
@@ -650,10 +650,10 @@ static int rcar_du_cmm_init(struct rcar_du_device *rcdu)
 		int ret;
 
 		cmm = of_parse_phandle(np, "renesas,cmms", i);
-		if (IS_ERR(cmm)) {
+		if (!cmm) {
 			dev_err(rcdu->dev,
 				"Failed to parse 'renesas,cmms' property\n");
-			return PTR_ERR(cmm);
+			return -ENODEV;
 		}
 
 		if (!of_device_is_available(cmm)) {
@@ -663,10 +663,10 @@ static int rcar_du_cmm_init(struct rcar_du_device *rcdu)
 		}
 
 		pdev = of_find_device_by_node(cmm);
-		if (IS_ERR(pdev)) {
+		if (!pdev) {
 			dev_err(rcdu->dev, "No device found for CMM%u\n", i);
 			of_node_put(cmm);
-			return PTR_ERR(pdev);
+			return -ENODEV;
 		}
 
 		of_node_put(cmm);
Acked-by on v1 1/1
#1 lore raw

Hello Wei,

Quoted 6 lines · Wei Yongjun

In case of error, the function of_parse_phandle()/of_find_device_by_node() returns NULL pointer not ERR_PTR(). The IS_ERR() test in the return value check should be replaced with NULL test

Fixes 8de707aeb452 ("drm: rcar-du: kms: Initialize CMM instances")

Correct indeed! Also -ENODEV seems appropriate to me as return value. Thanks!

Quoted 37 lines
---
 drivers/gpu/drm/rcar-du/rcar_du_kms.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/rcar-du/rcar_du_kms.c +4 -4
index 482329102f19..0da711d9b2f8 100644
@@ -650,10 +650,10 @@ static int rcar_du_cmm_init(struct rcar_du_device *rcdu)
 		int ret;
 
 		cmm = of_parse_phandle(np, "renesas,cmms", i);
-		if (IS_ERR(cmm)) {
+		if (!cmm) {
 			dev_err(rcdu->dev,
 				"Failed to parse 'renesas,cmms' property\n");
-			return PTR_ERR(cmm);
+			return -ENODEV;
 		}
 
 		if (!of_device_is_available(cmm)) {
@@ -663,10 +663,10 @@ static int rcar_du_cmm_init(struct rcar_du_device *rcdu)
 		}
 
 		pdev = of_find_device_by_node(cmm);
-		if (IS_ERR(pdev)) {
+		if (!pdev) {
 			dev_err(rcdu->dev, "No device found for CMM%u\n", i);
 			of_node_put(cmm);
-			return PTR_ERR(pdev);
+			return -ENODEV;
 		}
 
 		of_node_put(cmm);
Reviewed-by on v1 1/1
#2 lore raw
In reply to Wei Yongjun
Quoted 6 lines · Wei Yongjun

In case of error, the function of_parse_phandle()/of_find_device_by_node() returns NULL pointer not ERR_PTR(). The IS_ERR() test in the return value check should be replaced with NULL test

Fixes 8de707aeb452 ("drm: rcar-du: kms: Initialize CMM instances")

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds