Re: [PATCH v2] usb: udc: core: Use lock when write to soft_connect

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

 



Andy Shevchenko wrote:
>
>
> On Thursday, January 14, 2021, Ahmed S. Darwish
> <a.darwish@xxxxxxxxxxxxx <mailto:a.darwish@xxxxxxxxxxxxx>> wrote:
>
>     On Wed, Jan 13, 2021 at 07:38:28PM -0800, Thinh Nguyen wrote:
>     ...
>     > @@ -1543,10 +1546,12 @@ static ssize_t soft_connect_store(struct
>     device *dev,
>     >               usb_gadget_udc_stop(udc);
>     >       } else {
>     >               dev_err(dev, "unsupported command '%s'\n", buf);
>     > -             return -EINVAL;
>     > +             ret = -EINVAL;
>     >       }
>     >
>     > -     return n;
>
>
>
> Should be ret = n; here.
>  
>
>     > +out:
>     > +     mutex_unlock(&udc_lock);
>     > +     return ret;
>     >  }
>
>     This is *very* tricky: the return value will be easily broken if
>     someone
>     adds any code later after the else body and before the "out" label.
>
>
>
> +1 and it’s not good pattern to assign return value at the definition
> time (see comment above ). 
>
>
> -- 
> With Best Regards,
> Andy Shevchenko
>
>

Good point. I didn't think about that. Thanks guys.

Thinh




[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux