drm: rcar-du: Fix the return check of of_parse_phandle and of_find_device_by_node
authorWang Xiaojun <wangxiaojun11@huawei.com>
Wed, 11 Nov 2020 03:14:52 +0000 (11:14 +0800)
committerLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Tue, 5 Jan 2021 05:20:11 +0000 (07:20 +0200)
of_parse_phandle and of_find_device_by_node may return NULL
which cannot be checked by IS_ERR.

Fixes: 8de707aeb452 ("drm: rcar-du: kms: Initialize CMM instances")
Signed-off-by: Wang Xiaojun <wangxiaojun11@huawei.com>
Reported-by: Hulk Robot <hulkci@huawei.com>
Acked-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
[Replace -ENODEV with -EINVAL]

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
drivers/gpu/drm/rcar-du/rcar_du_kms.c

index d6b71a9361ca6c312d3c450b445aeacc91eafa92..92dfa3d4c011a4601de113ed5f6bcd417d1bcc41 100644 (file)
@@ -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 -EINVAL;
                }
 
                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 -EINVAL;
                }
 
                of_node_put(cmm);