diff mbox series

media: nuvoton: npcm-video: Fix IS_ERR() vs NULL bug

Message ID 3134a802-75fe-49f3-bcd6-06addc2ffaf5@moroto.mountain (mailing list archive)
State New, archived
Headers show
Series media: nuvoton: npcm-video: Fix IS_ERR() vs NULL bug | expand

Commit Message

Dan Carpenter Sept. 27, 2023, 12:39 p.m. UTC
The of_parse_phandle() function returns NULL on error.  It never returns
error pointers.  Update the check accordingly.

Fixes: 70721089985c ("media: nuvoton: Add driver for NPCM video capture and encoding engine")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/media/platform/nuvoton/npcm-video.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Marvin Lin Oct. 3, 2023, 12:02 p.m. UTC | #1
Hi Dan,

Thanks for the patch.

> The of_parse_phandle() function returns NULL on error.  It never returns
> error pointers.  Update the check accordingly.

Commit message contains some redundant whitespaces.

>
> Fixes: 70721089985c ("media: nuvoton: Add driver for NPCM video capture and encoding engine")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>  drivers/media/platform/nuvoton/npcm-video.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/platform/nuvoton/npcm-video.c b/drivers/media/platform/nuvoton/npcm-video.c
> index ac8d73b794d3..b9e6782f59b4 100644
> --- a/drivers/media/platform/nuvoton/npcm-video.c
> +++ b/drivers/media/platform/nuvoton/npcm-video.c
> @@ -1660,9 +1660,9 @@ static int npcm_video_ece_init(struct npcm_video *video)
>         void __iomem *regs;
>
>         ece_node = of_parse_phandle(video->dev->of_node, "nuvoton,ece", 0);
> -       if (IS_ERR(ece_node)) {
> +       if (!ece_node) {
>                 dev_err(dev, "Failed to get ECE phandle in DTS\n");
> -               return PTR_ERR(ece_node);
> +               return -ENODEV;
>         }
>
>         video->ece.enable = of_device_is_available(ece_node);

Others,
Reviewed-by: Marvin Lin <milkfafa@gmail.com>

Regards,
Marvin
Dan Carpenter Oct. 3, 2023, 12:49 p.m. UTC | #2
On Tue, Oct 03, 2023 at 08:02:33PM +0800, Kun-Fa Lin wrote:
> Hi Dan,
> 
> Thanks for the patch.
> 
> > The of_parse_phandle() function returns NULL on error.  It never returns
> > error pointers.  Update the check accordingly.
> 
> Commit message contains some redundant whitespaces.
> 

I have no idea what you're talking about?  Are you talking about two
spaces after a period?  :P

regards,
dan carpenter
Marvin Lin Oct. 3, 2023, 1:09 p.m. UTC | #3
> On Tue, Oct 03, 2023 at 08:02:33PM +0800, Kun-Fa Lin wrote:
> > Hi Dan,
> >
> > Thanks for the patch.
> >
> > > The of_parse_phandle() function returns NULL on error.  It never returns

                          ^^
> > > error pointers.  Update the check accordingly.
                               ^^
> >
> > Commit message contains some redundant whitespaces.
> >
>
> I have no idea what you're talking about?  Are you talking about two
> spaces after a period?  :P
>

Yes :P

Regards,
Marvin
diff mbox series

Patch

diff --git a/drivers/media/platform/nuvoton/npcm-video.c b/drivers/media/platform/nuvoton/npcm-video.c
index ac8d73b794d3..b9e6782f59b4 100644
--- a/drivers/media/platform/nuvoton/npcm-video.c
+++ b/drivers/media/platform/nuvoton/npcm-video.c
@@ -1660,9 +1660,9 @@  static int npcm_video_ece_init(struct npcm_video *video)
 	void __iomem *regs;
 
 	ece_node = of_parse_phandle(video->dev->of_node, "nuvoton,ece", 0);
-	if (IS_ERR(ece_node)) {
+	if (!ece_node) {
 		dev_err(dev, "Failed to get ECE phandle in DTS\n");
-		return PTR_ERR(ece_node);
+		return -ENODEV;
 	}
 
 	video->ece.enable = of_device_is_available(ece_node);