linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oliver Neukum <oneukum@suse.com>
To: Marcel Holtmann <marcel@holtmann.org>,
	Jeffy Chen <jeffy.chen@rock-chips.com>
Cc: linux-kernel@vger.kernel.org, xiyou.wangcong@gmail.com,
	briannorris@chromium.org, dianders@chromium.org,
	Johan Hedberg <johan.hedberg@gmail.com>,
	"Gustavo F. Padovan" <gustavo@padovan.org>,
	linux-bluetooth@vger.kernel.org
Subject: Re: [RFC PATCH v2] Bluetooth: btusb: Fix memory leak in play_deferred
Date: Tue, 18 Jul 2017 09:30:15 +0200	[thread overview]
Message-ID: <1500363015.16072.5.camel@suse.com> (raw)
In-Reply-To: <6E21F79E-93AA-4461-BA6B-67715501714F@holtmann.org>

Am Dienstag, den 18.07.2017, 08:44 +0200 schrieb Marcel Holtmann:
> > diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
> > index 0d533b2..a22a08b 100644
> > --- a/drivers/bluetooth/btusb.c
> > +++ b/drivers/bluetooth/btusb.c
> > @@ -3260,19 +3260,33 @@ static int btusb_suspend(struct usb_interface *intf, pm_message_t message)
> >       return 0;
> > }
> > 
> > +static void btusb_deferred_tx_complete(struct urb *urb)
> > +{
> > +     btusb_tx_complete(urb);
> > +     usb_free_urb(urb);
> > +}
> > +
> > static void play_deferred(struct btusb_data *data)
> > {
> >       struct urb *urb;
> >       int err;
> > 
> >       while ((urb = usb_get_from_anchor(&data->deferred))) {
> > +             /* Add a hook to free urb after completed */
> > +             urb->complete = btusb_deferred_tx_complete;
> > +
> >               err = usb_submit_urb(urb, GFP_ATOMIC);
> > -             if (err < 0)
> > -                     break;
> > +             if (err < 0) {
> > +                     if (err != -EPERM && err != -ENODEV)
> > +                             BT_ERR("%s urb %p submission failed (%d)",
> > +                                    data->hdev->name, urb, -err);
> > +                     kfree(urb->setup_packet);
> > +                     usb_free_urb(urb);
> > +                     continue;
> > +             }
> > 
> >               data->tx_in_flight++;
> >       }
> > -     usb_scuttle_anchored_urbs(&data->deferred);
> > }
> 
> can I get an ack from you on this one?

Hi,

I am afraid not. We cannot silently drop one part of a transmission.
I am afraid that the correct algorithm, if we encounter an error at
that stage, is to abort the operation and report an error.

	Regards
		Oliver

  reply	other threads:[~2017-07-18  7:32 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-18  2:06 [RFC PATCH v2] Bluetooth: btusb: Fix memory leak in play_deferred Jeffy Chen
2017-07-18  6:44 ` Marcel Holtmann
2017-07-18  7:30   ` Oliver Neukum [this message]
2017-07-18  8:08     ` jeffy
2017-07-18  8:41       ` Oliver Neukum
2017-07-18  9:36         ` jeffy
2017-07-18  9:41           ` Oliver Neukum
2017-07-18  9:56             ` jeffy
2017-07-18 12:29               ` Oliver Neukum
2017-07-18 13:13                 ` jeffy
  -- strict thread matches above, loose matches on Subject: below --
2017-07-18  2:05 Jeffy Chen

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=1500363015.16072.5.camel@suse.com \
    --to=oneukum@suse.com \
    --cc=briannorris@chromium.org \
    --cc=dianders@chromium.org \
    --cc=gustavo@padovan.org \
    --cc=jeffy.chen@rock-chips.com \
    --cc=johan.hedberg@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcel@holtmann.org \
    --cc=xiyou.wangcong@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).