Linux bluetooth development
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: marcel@holtmann.org
Cc: linux-bluetooth@vger.kernel.org, Laura Abbott <labbott@redhat.com>
Subject: [bug report] Bluetooth: Fix memory leaking when hdev->send returns an error
Date: Tue, 23 May 2017 08:34:00 +0300	[thread overview]
Message-ID: <20170523053400.GA3371@elgon.mountain> (raw)

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

             reply	other threads:[~2017-05-23  5:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-23  5:34 Dan Carpenter [this message]
2017-05-23  9:27 ` [bug report] Bluetooth: Fix memory leaking when hdev->send returns an error Loic Poulain

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=20170523053400.GA3371@elgon.mountain \
    --to=dan.carpenter@oracle.com \
    --cc=labbott@redhat.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=marcel@holtmann.org \
    /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