lkml.org 
[lkml]   [2021]   [Dec]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v3 2/2] usb: gadget: clear related members when goto fail
On Fri, Dec 31, 2021 at 10:31:51AM +0800, Hangyu Hua wrote:
> On 2021/12/31 上午3:46, Alan Stern wrote:

> >> @@ -1892,7 +1895,12 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
> >> }
> >> return value;
> >>
> >> +fail2:
> >> + dev->dev = NULL;
> >> +fail1:
> >> + dev->hs_config = NULL;
> >
> > It is not necessary to have all these different statement labels. You
> > can simply have "fail:" clear all three pointers.

> I don't think so. It is not necessary to clean all three pointers if
> some of them aren't kbuf. I think it may be better to keep their own
> pointers.

If the pointers aren't set to a region inside kbuf then they are
meaningless. There is no reason to keep the old values. It is better
to avoid multiple unnecessary statement labels.

Alan Stern

\
 
 \ /
  Last update: 2021-12-31 16:59    [W:1.248 / U:0.248 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site