public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Andrey Konovalov <andreyknvl@google.com>
Cc: USB list <linux-usb@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Alan Stern <stern@rowland.harvard.edu>,
	Jonathan Corbet <corbet@lwn.net>, Felipe Balbi <balbi@kernel.org>,
	Dmitry Vyukov <dvyukov@google.com>,
	Alexander Potapenko <glider@google.com>,
	Marco Elver <elver@google.com>
Subject: Re: [PATCH 1/1] usb: gadget: add raw-gadget interface
Date: Fri, 15 Nov 2019 11:19:51 +0800	[thread overview]
Message-ID: <20191115031951.GA793701@kroah.com> (raw)
In-Reply-To: <CAAeHK+w-nB4MngSNhazkZAa-Ovdu1C45HaD6XCPoJ79qRo8keQ@mail.gmail.com>

On Thu, Nov 14, 2019 at 04:08:29PM +0100, Andrey Konovalov wrote:
> On Fri, Nov 8, 2019 at 10:17 PM Greg Kroah-Hartman
> > > +static void gadget_unbind(struct usb_gadget *gadget)
> > > +{
> > > +     struct raw_dev *dev = get_gadget_data(gadget);
> > > +     unsigned long flags;
> > > +
> > > +     if (WARN_ON(!dev))
> > > +             return;
> >
> > Why warn?  How can this happen?
> 
> This shouldn't happen and I initially had BUG_ON there, but checkpatch
> complained. I can use BUG_ON of leave it as WARN_ON, which would you
> prefer?

If it should never happen, then why test it?
If it can happen, then just test and print an error, why panic the
machine if panic-on-warn is enabled for something that we can test and
recover from?

And no, never add BUG_ON please.

> > > +static int raw_open(struct inode *inode, struct file *fd)
> > > +{
> > > +     struct raw_dev *dev;
> > > +
> > > +     dev = dev_new();
> > > +     if (!dev) {
> > > +             pr_err("failed to created device");
> >
> > So many error messages printed on failures, you only needed the original
> > one if memory was gone that the core sent out.
> 
> What do you mean by the original one? I see only one error printed in
> case dev_new() fails. However I'm not sure if there's much value in
> printing an error in case the kernel ran out of memory, as it doesn't
> handle this very well anyway AFAIK. Should I remove this pr_err?

Yes, please do.

thanks,

greg k-h

  parent reply	other threads:[~2019-11-15  3:19 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-08 18:26 [PATCH 0/1] usb: gadget: add raw-gadget interface Andrey Konovalov
2019-11-08 18:26 ` [PATCH 1/1] " Andrey Konovalov
2019-11-08 21:17   ` Greg Kroah-Hartman
2019-11-08 22:17     ` Andrey Konovalov
2019-11-14 15:08     ` Andrey Konovalov
2019-11-14 15:33       ` Andrey Konovalov
2019-11-15  3:20         ` Greg Kroah-Hartman
2019-11-15  3:19       ` Greg Kroah-Hartman [this message]
2019-11-08 21:45 ` [PATCH 0/1] " Alan Stern
2019-11-08 22:18   ` Andrey Konovalov
2019-11-14 15:10     ` Andrey Konovalov
2019-11-14 15:56       ` Alan Stern

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=20191115031951.GA793701@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=andreyknvl@google.com \
    --cc=balbi@kernel.org \
    --cc=corbet@lwn.net \
    --cc=dvyukov@google.com \
    --cc=elver@google.com \
    --cc=glider@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox