[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191115031951.GA793701@kroah.com>
Date: Fri, 15 Nov 2019 11:19:51 +0800
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: Andrey Konovalov <andreyknvl@...gle.com>
Cc: USB list <linux-usb@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>,
Alan Stern <stern@...land.harvard.edu>,
Jonathan Corbet <corbet@....net>,
Felipe Balbi <balbi@...nel.org>,
Dmitry Vyukov <dvyukov@...gle.com>,
Alexander Potapenko <glider@...gle.com>,
Marco Elver <elver@...gle.com>
Subject: Re: [PATCH 1/1] usb: gadget: add raw-gadget interface
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
Powered by blists - more mailing lists