From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>,
"Ahmed S. Darwish" <a.darwish@linutronix.de>
Cc: Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
Felipe Balbi <balbi@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
Peter Chen <peter.chen@nxp.com>, Lee Jones <lee.jones@linaro.org>,
Alan Stern <stern@rowland.harvard.edu>,
Dejin Zheng <zhengdejin5@gmail.com>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Michal Nazarewicz <mina86@mina86.com>,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH v2] usb: udc: core: Use lock when write to soft_connect
Date: Thu, 14 Jan 2021 08:00:10 +0000 [thread overview]
Message-ID: <62fb4dc5-d9f7-e58d-d4c4-17a4c78a1d3e@synopsys.com> (raw)
In-Reply-To: <CAHp75Vf3eZjg20QEr6YqdY7R1Eu=D2za+sKb0vVBaAmETg1z4Q@mail.gmail.com>
Andy Shevchenko wrote:
>
>
> On Thursday, January 14, 2021, Ahmed S. Darwish
> <a.darwish@linutronix.de <mailto:a.darwish@linutronix.de>> 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
next prev parent reply other threads:[~2021-01-14 8:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-14 3:38 [PATCH v2] usb: udc: core: Use lock when write to soft_connect Thinh Nguyen
2021-01-14 6:41 ` Ahmed S. Darwish
[not found] ` <CAHp75Vf3eZjg20QEr6YqdY7R1Eu=D2za+sKb0vVBaAmETg1z4Q@mail.gmail.com>
2021-01-14 8:00 ` Thinh Nguyen [this message]
2021-01-14 9:06 ` Greg Kroah-Hartman
2021-01-14 8:56 ` Felipe Balbi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=62fb4dc5-d9f7-e58d-d4c4-17a4c78a1d3e@synopsys.com \
--to=thinh.nguyen@synopsys.com \
--cc=a.darwish@linutronix.de \
--cc=andy.shevchenko@gmail.com \
--cc=balbi@kernel.org \
--cc=bigeasy@linutronix.de \
--cc=gregkh@linuxfoundation.org \
--cc=lee.jones@linaro.org \
--cc=linux-usb@vger.kernel.org \
--cc=mina86@mina86.com \
--cc=peter.chen@nxp.com \
--cc=stable@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
--cc=zhengdejin5@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.