From: jeffy <jeffy.chen@rock-chips.com>
To: Oliver Neukum <oneukum@suse.com>, Marcel Holtmann <marcel@holtmann.org>
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 16:08:32 +0800 [thread overview]
Message-ID: <596DC200.1080006@rock-chips.com> (raw)
In-Reply-To: <1500363015.16072.5.camel@suse.com>
Hi Oliver,
On 07/18/2017 03:30 PM, Oliver Neukum wrote:
> 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.
>
so i should break the loop when error happens right?
and i uploaded 2 version of patches, which one do you prefer to go on?
> Regards
> Oliver
>
>
>
>
next prev parent reply other threads:[~2017-07-18 8:08 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
2017-07-18 8:08 ` jeffy [this message]
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=596DC200.1080006@rock-chips.com \
--to=jeffy.chen@rock-chips.com \
--cc=briannorris@chromium.org \
--cc=dianders@chromium.org \
--cc=gustavo@padovan.org \
--cc=johan.hedberg@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcel@holtmann.org \
--cc=oneukum@suse.com \
--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).