drm: rcar-du: Fix the return check of of_parse_phandle and of_find_device_by_node
Subsystems (3)
PATCH 1/1 drm: rcar-du: Fix the return check of of_parse_phandle and of_find_device_by_node
of_parse_phandle and of_find_device_by_node may return NULL which cannot be checked by IS_ERR.
--- 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
@@ -700,10 +700,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)) {
@@ -713,10 +713,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);
Signature · 1 line
2.25.1
Hi Wang Xiaojun,
Quoted 2 lines · Wang Xiaojun
of_parse_phandleandof_find_device_by_nodemay return NULL which cannot be checked byIS_ERR.
Indeed, both of these functions return either NULL or the correct value, and no an errno.
Quoted 3 lines
Signed-off-by Wang Xiaojun <[email protected]>Reported-by Hulk Robot <[email protected]>
Quoted 35 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@@ -700,10 +700,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)) {@@ -713,10 +713,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);
Hi Wang,
Thank you for the patch.
Quoted 5 lines · Wang Xiaojun
of_parse_phandleandof_find_device_by_nodemay return NULL which cannot be checked byIS_ERR.Signed-off-by Wang Xiaojun <[email protected]>Reported-by Hulk Robot <[email protected]>
and queued in my tree for v5.12.
Quoted 34 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@@ -700,10 +700,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)) {@@ -713,10 +713,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);
Signature · 7 lines
Regards, Laurent Pinchart _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 26 lines · Laurent Pinchart
Hi Wang,
Thank you for the patch.
Quoted 5 lines · Wang Xiaojun
of_parse_phandleandof_find_device_by_nodemay return NULL which cannot be checked byIS_ERR.Signed-off-by Wang Xiaojun <[email protected]>Reported-by Hulk Robot <[email protected]>Reviewed-by Laurent Pinchart <[email protected]>and queued in my tree for v5.12.
Quoted 11 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 +0
-0@@ -700,10 +700,10 @@ static int rcar_du_cmm_init(struct rcar_du_device *rcdu)int ret;
Quoted 7 lines
drivers/gpu/drm/rcar-du/rcar_du_kms.c static int rcar_du_cmm_init(struct rcar_du_device *rcdu) · line 706
Quoted 7 lines
drivers/gpu/drm/rcar-du/rcar_du_kms.c +2
-2cmm =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 ;
Actually, this should return -EINVAL, as this error really shouldn't happen. Same below. I'll update this, no need to resend a new version.
Quoted 16 lines
Quoted 16 lines
drivers/gpu/drm/rcar-du/rcar_du_kms.c +2
-2}if (!of_device_is_available (cmm)) {@@ -713,10 +713,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);
Signature · 7 lines
Regards, Laurent Pinchart _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel