Skip to content

Commit

Permalink
Bluetooth: Fix memory leak in read_adv_mon_features()
Browse files Browse the repository at this point in the history
[ Upstream commit cafd472 ]

read_adv_mon_features() is leaking memory. Free `rp` before returning.

Fixes: e5e1e7f ("Bluetooth: Add handler of MGMT_OP_READ_ADV_MONITOR_FEATURES")
Reported-and-tested-by: syzbot+f7f6e564f4202d8601c6@syzkaller.appspotmail.com
Link: https://syzkaller.appspot.com/bug?extid=f7f6e564f4202d8601c6
Signed-off-by: Peilin Ye <yepeilin.cs@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
ypl-coffee authored and gregkh committed Oct 29, 2020
1 parent ba187d7 commit e7114c3
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions net/bluetooth/mgmt.c
Expand Up @@ -4162,7 +4162,7 @@ static int read_adv_mon_features(struct sock *sk, struct hci_dev *hdev,
{
struct adv_monitor *monitor = NULL;
struct mgmt_rp_read_adv_monitor_features *rp = NULL;
int handle;
int handle, err;
size_t rp_size = 0;
__u32 supported = 0;
__u16 num_handles = 0;
Expand Down Expand Up @@ -4197,9 +4197,13 @@ static int read_adv_mon_features(struct sock *sk, struct hci_dev *hdev,
if (num_handles)
memcpy(&rp->handles, &handles, (num_handles * sizeof(u16)));

return mgmt_cmd_complete(sk, hdev->id,
MGMT_OP_READ_ADV_MONITOR_FEATURES,
MGMT_STATUS_SUCCESS, rp, rp_size);
err = mgmt_cmd_complete(sk, hdev->id,
MGMT_OP_READ_ADV_MONITOR_FEATURES,
MGMT_STATUS_SUCCESS, rp, rp_size);

kfree(rp);

return err;
}

static int add_adv_patterns_monitor(struct sock *sk, struct hci_dev *hdev,
Expand Down

0 comments on commit e7114c3

Please sign in to comment.