media: nuvoton: Fix an error check in npcm_video_ece_init()
authorZhen Lei <thunder.leizhen@huawei.com>
Tue, 15 Oct 2024 01:40:53 +0000 (09:40 +0800)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Wed, 8 Jan 2025 14:59:59 +0000 (14:59 +0000)
When function of_find_device_by_node() fails, it returns NULL instead of
an error code. So the corresponding error check logic should be modified
to check whether the return value is NULL and set the error code to be
returned as -ENODEV.

Fixes: 46c15a4ff1f4 ("media: nuvoton: Add driver for NPCM video capture and encoding engine")
Cc: stable@vger.kernel.org
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Link: https://lore.kernel.org/r/20241015014053.669-1-thunder.leizhen@huawei.com
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/platform/nuvoton/npcm-video.c

index 4f5d75645b2bb94669d976f9bfe7a9870f92c481..024cd8ee17098d62512175c416a1e0cc932c1910 100644 (file)
@@ -1665,9 +1665,9 @@ static int npcm_video_ece_init(struct npcm_video *video)
                dev_info(dev, "Support HEXTILE pixel format\n");
 
                ece_pdev = of_find_device_by_node(ece_node);
-               if (IS_ERR(ece_pdev)) {
+               if (!ece_pdev) {
                        dev_err(dev, "Failed to find ECE device\n");
-                       return PTR_ERR(ece_pdev);
+                       return -ENODEV;
                }
                of_node_put(ece_node);