All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oliver Neukum <oneukum@suse.com>
To: "Bjørn Mork" <bjorn@mork.no>
Cc: gustavo@embeddedor.com, andreyknvl@google.com,
	syzkaller-bugs@googlegroups.com, gregkh@linuxfoundation.org,
	syzbot <syzbot+d232cca6ec42c2edb3fc@syzkaller.appspotmail.com>,
	linux-usb@vger.kernel.org
Subject: Re: WARNING in wdm_write/usb_submit_urb
Date: Tue, 20 Aug 2019 14:27:01 +0200	[thread overview]
Message-ID: <1566304021.11678.13.camel@suse.com> (raw)
In-Reply-To: <87sgpw5d6j.fsf@miraculix.mork.no>

Am Dienstag, den 20.08.2019, 12:44 +0200 schrieb Bjørn Mork :
> Oliver Neukum <oneukum@suse.com> writes:
> 
> > diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
> > index 1656f5155ab8..a341081a5f47 100644
> > --- a/drivers/usb/class/cdc-wdm.c
> > +++ b/drivers/usb/class/cdc-wdm.c
> > @@ -588,14 +588,24 @@ static int wdm_flush(struct file *file, fl_owner_t id)
> >  {
> >  	struct wdm_device *desc = file->private_data;
> >  
> > -	wait_event(desc->wait, !test_bit(WDM_IN_USE, &desc->flags));
> > +	wait_event(desc->wait,
> > +			/*
> > +			 * needs both flags. We cannot do with one
> > +			 * because resetting it would cause a race
> > +			 * with write() yet we need to signal
> > +			 * a disconnect
> > +			 */
> > +			!test_bit(WDM_IN_USE, &desc->flags) &&
> > +			!test_bit(WDM_DISCONNECTING, &desc->flags));
> 
> 
> Makes sense.  But isn't the WDM_DISCONNECTING test inverted?

You are right. I am making V3.

> >  	/* cannot dereference desc->intf if WDM_DISCONNECTING */
> >  	if (desc->werr < 0 && !test_bit(WDM_DISCONNECTING, &desc->flags))
> >  		dev_err(&desc->intf->dev, "Error in flush path: %d\n",
> >  			desc->werr);
> >  
> > -	return usb_translate_errors(desc->werr);
> > +	return test_bit(WDM_DISCONNECTING, &desc->flags) ? 
> > +			-ENODEV : 
> > +			usb_translate_errors(desc->werr);
> >  }
> 
> Minor detail, but there's an awful lot of test_bit(WDM_DISCONNECTING)
> here.  How about
> 
>   if (test_bit(WDM_DISCONNECTING, &desc->flags))
>     return -ENODEV;
>   if (desc->werr < 0)
>     dev_err(&desc->intf->dev, "Error in flush path: %d\n", desc->werr);
>   return usb_translate_errors(desc->werr);

Much better.

	Regards
		Oliver


  reply	other threads:[~2019-08-20 12:27 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-19 14:48 WARNING in wdm_write/usb_submit_urb syzbot
2019-08-20  0:50 ` syzbot
2019-08-20 10:31   ` Oliver Neukum
2019-08-20 10:44     ` Bjørn Mork
2019-08-20 12:27       ` Oliver Neukum [this message]
2019-08-20 10:45     ` syzbot
2019-08-20 10:59   ` Oliver Neukum
2019-08-20 11:18     ` syzbot
2019-08-20 12:28   ` Oliver Neukum
2019-08-20 12:48     ` syzbot
2019-08-20 13:13     ` Bjørn Mork
2019-08-20 13:40       ` Oliver Neukum
2019-08-20 13:41   ` Oliver Neukum
2019-08-20 14:00     ` syzbot

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=1566304021.11678.13.camel@suse.com \
    --to=oneukum@suse.com \
    --cc=andreyknvl@google.com \
    --cc=bjorn@mork.no \
    --cc=gregkh@linuxfoundation.org \
    --cc=gustavo@embeddedor.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=syzbot+d232cca6ec42c2edb3fc@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.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.