Re: [PATCH v4 1/1] drm/bridge: lt8912b: Fix issues found during static analysis

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

 



On Wed, Mar 31, 2021 at 02:57:31PM +0200, Andrzej Hajda wrote:
> >   
> >   	if (!of_device_is_compatible(port_node, "hdmi-connector")) {
> >   		dev_err(lt->dev, "%s: Failed to get hdmi port\n", __func__);
> > +		of_node_put(port_node);
> >   		ret = -EINVAL;
> > +		goto err_free_host_node;
> 
> Maybe better would be to put of_node_put(port_node) after 
> err_free_host_node label - of_node_put(NULL) does nothing.
> 

I prefer this style for several reasons:
1) I kind of hate no-op puts
2) The port_node is not part of the wind up in the sense that we don't
   leave hold the reference on the success path.  It's the same with
   locking, I prefer if unlock happens before the goto.  Sometimes
   people do an unlock as part of the unwind but this style only works
   for the first label in the unwind path.
3) I like when you can copy and paste the unwind code to create the
   release function, lt8912_put_dt() in this example.  Normally you have
   to add one more release function because most times the last failure
   path is an allocation but in this case the release is just
   of_node_put(lt->host_node);

But, yeah, putting the of_node_put() after the label isn't bug so
whatever...

regards,
dan carpenter

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel



[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux