Skip to content

Commit cafd472

Browse files
peilin-yeholtmann
authored andcommitted
Bluetooth: Fix memory leak in read_adv_mon_features()
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>
1 parent 2041a3f commit cafd472

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

‎net/bluetooth/mgmt.c‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4157,7 +4157,7 @@ static int read_adv_mon_features(struct sock *sk, struct hci_dev *hdev,
41574157
{
41584158
struct adv_monitor *monitor = NULL;
41594159
struct mgmt_rp_read_adv_monitor_features *rp = NULL;
4160-
int handle;
4160+
int handle, err;
41614161
size_t rp_size = 0;
41624162
__u32 supported = 0;
41634163
__u16 num_handles = 0;
@@ -4192,9 +4192,13 @@ static int read_adv_mon_features(struct sock *sk, struct hci_dev *hdev,
41924192
if (num_handles)
41934193
memcpy(&rp->handles, &handles, (num_handles * sizeof(u16)));
41944194

4195-
return mgmt_cmd_complete(sk, hdev->id,
4196-
MGMT_OP_READ_ADV_MONITOR_FEATURES,
4197-
MGMT_STATUS_SUCCESS, rp, rp_size);
4195+
err = mgmt_cmd_complete(sk, hdev->id,
4196+
MGMT_OP_READ_ADV_MONITOR_FEATURES,
4197+
MGMT_STATUS_SUCCESS, rp, rp_size);
4198+
4199+
kfree(rp);
4200+
4201+
return err;
41984202
}
41994203

42004204
static int add_adv_patterns_monitor(struct sock *sk, struct hci_dev *hdev,

0 commit comments

Comments
 (0)