Linux bluetooth development
 help / color / mirror / Atom feed
* [bug report] Bluetooth: Fix memory leaking when hdev->send returns an error
@ 2017-05-23  5:34 Dan Carpenter
  2017-05-23  9:27 ` Loic Poulain
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2017-05-23  5:34 UTC (permalink / raw)
  To: marcel; +Cc: linux-bluetooth, Laura Abbott

Hello Marcel Holtmann,

The patch cdc52faac5f3: "Bluetooth: Fix memory leaking when
hdev->send returns an error" from Jul 6, 2014, leads to the following
static checker warning:

	net/bluetooth/hci_core.c:3385 hci_send_frame()
	warn: 'skb' was already freed.

net/bluetooth/hci_core.c
  3377          if (!test_bit(HCI_RUNNING, &hdev->flags)) {
  3378                  kfree_skb(skb);
  3379                  return;
  3380          }
  3381  
  3382          err = hdev->send(hdev, skb);
  3383          if (err < 0) {
  3384                  BT_ERR("%s sending frame failed (%d)", hdev->name, err);
  3385                  kfree_skb(skb);
  3386          }


The ti_st_send_frame() frees skb on error.  I'm surprised this bug
wasn't found by KAsan when we found acf91ec384dd ("Bluetooth: btwilink:
Save the packet type before sending").

I don't totally understand how skb is freed on the success path either.
bfusb_send_frame(), dtl1_hci_send_frame() and btqcomsmd_send() have
calls to kfree_skb() but I can't find the calls in bpa10x_send_frame()
or the other ->send functions.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [bug report] Bluetooth: Fix memory leaking when hdev->send returns an error
  2017-05-23  5:34 [bug report] Bluetooth: Fix memory leaking when hdev->send returns an error Dan Carpenter
@ 2017-05-23  9:27 ` Loic Poulain
  0 siblings, 0 replies; 2+ messages in thread
From: Loic Poulain @ 2017-05-23  9:27 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: marcel, linux-bluetooth, Laura Abbott

Hi Dan,


On 23/05/2017 07:34, Dan Carpenter wrote:
> The ti_st_send_frame() frees skb on error.  I'm surprised this bug
> wasn't found by KAsan when we found acf91ec384dd ("Bluetooth: btwilink:
> Save the packet type before sending").

Maybe an unreachable condition in the current ti_st implementation.
But yes this needs to be fixed.

> I don't totally understand how skb is freed on the success path either.
> bfusb_send_frame(), dtl1_hci_send_frame() and btqcomsmd_send() have
> calls to kfree_skb() but I can't find the calls in bpa10x_send_frame()
> or the other ->send functions.

bpa10x_send_frame stores a skb reference when filling urb, skb is then freed
asynchronously in the bpa10x_tx_complete callback.
What are the other send functions ? bt skb is often enqueued and not 
released
in the send function itself.

Regards,
Loic

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-05-23  9:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-23  5:34 [bug report] Bluetooth: Fix memory leaking when hdev->send returns an error Dan Carpenter
2017-05-23  9:27 ` Loic Poulain

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox