Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1689853

Re: [RFC PATCH v2] Bluetooth: btusb: Fix memory leak in play_deferred

From jeffy <jeffy.chen@rock-chips.com>
Newsgroups linux.kernel
Subject Re: [RFC PATCH v2] Bluetooth: btusb: Fix memory leak in play_deferred
Date 2017-07-18 10:10 +0200
Message-ID <u4vJU-8k9-13@gated-at.bofh.it> (permalink)
References <u4q7w-4KD-1@gated-at.bofh.it> <u4uut-7ol-13@gated-at.bofh.it> <u4vgS-7Vc-21@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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
>
>
>
>

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[RFC PATCH v2] Bluetooth: btusb: Fix memory leak in play_deferred Jeffy Chen <jeffy.chen@rock-chips.com> - 2017-07-18 04:10 +0200
  Re: [RFC PATCH v2] Bluetooth: btusb: Fix memory leak in play_deferred Marcel Holtmann <marcel@holtmann.org> - 2017-07-18 08:50 +0200
    Re: [RFC PATCH v2] Bluetooth: btusb: Fix memory leak in  play_deferred Oliver Neukum <oneukum@suse.com> - 2017-07-18 09:40 +0200
      Re: [RFC PATCH v2] Bluetooth: btusb: Fix memory leak in play_deferred jeffy <jeffy.chen@rock-chips.com> - 2017-07-18 10:10 +0200
        Re: [RFC PATCH v2] Bluetooth: btusb: Fix memory leak in  play_deferred Oliver Neukum <oneukum@suse.com> - 2017-07-18 10:50 +0200
          Re: [RFC PATCH v2] Bluetooth: btusb: Fix memory leak in play_deferred jeffy <jeffy.chen@rock-chips.com> - 2017-07-18 11:40 +0200
            Re: [RFC PATCH v2] Bluetooth: btusb: Fix memory leak in  play_deferred Oliver Neukum <oneukum@suse.com> - 2017-07-18 11:50 +0200
              Re: [RFC PATCH v2] Bluetooth: btusb: Fix memory leak in play_deferred jeffy <jeffy.chen@rock-chips.com> - 2017-07-18 12:00 +0200
                Re: [RFC PATCH v2] Bluetooth: btusb: Fix memory leak in  play_deferred Oliver Neukum <oneukum@suse.com> - 2017-07-18 14:40 +0200
                Re: [RFC PATCH v2] Bluetooth: btusb: Fix memory leak in play_deferred jeffy <jeffy.chen@rock-chips.com> - 2017-07-18 15:20 +0200

csiph-web