Re: [PATCH] drm: rcar-du: Fix the return check of of_parse_phandle and of_find_device_by_node

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Dec 16, 2020 at 03:00:43AM +0200, Laurent Pinchart wrote:
> Hi Wang,
> 
> Thank you for the patch.
> 
> On Wed, Nov 11, 2020 at 11:14:52AM +0800, Wang Xiaojun wrote:
> > of_parse_phandle and of_find_device_by_node may return NULL
> > which cannot be checked by IS_ERR.
> > 
> > Signed-off-by: Wang Xiaojun <wangxiaojun11@xxxxxxxxxx>
> > Reported-by: Hulk Robot <hulkci@xxxxxxxxxx>
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@xxxxxxxxxxxxxxxx>
> 
> and queued in my tree for v5.12.
> 
> > ---
> >  drivers/gpu/drm/rcar-du/rcar_du_kms.c | 8 ++++----
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
> > index 72dda446355f..fcfddf7ad3f3 100644
> > --- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
> > +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
> > @@ -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;

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.

> >  		}
> >  
> >  		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);

-- 
Regards,

Laurent Pinchart



[Index of Archives]     [Linux Samsung SOC]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux