* [Linux-kernel-mentees] [PATCH] Bluetooth: Fix memory leak in read_adv_mon_features()
[not found] <00000000000033913705acedbd6b@google.com>
@ 2020-09-08 20:06 ` Peilin Ye
2020-09-09 7:25 ` [Linux-kernel-mentees] [PATCH v2] " Peilin Ye
0 siblings, 1 reply; 3+ messages in thread
From: Peilin Ye @ 2020-09-08 20:06 UTC (permalink / raw)
To: Marcel Holtmann, Johan Hedberg
Cc: Miao-chen Chou, syzkaller-bugs, linux-kernel, David S. Miller,
linux-bluetooth, Jakub Kicinski, linux-kernel-mentees, Peilin Ye
read_adv_mon_features() is leaking memory. Free `rp` before returning.
Fixes: e5e1e7fd470c ("Bluetooth: Add handler of MGMT_OP_READ_ADV_MONITOR_FEATURES")
Reported-and-tested-by: syzbot+f7f6e564f4202d8601c6@syzkaller.appspotmail.com
Signed-off-by: Peilin Ye <yepeilin.cs@gmail.com>
---
net/bluetooth/mgmt.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 5bbe71002fb9..f96251f818fc 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -4157,7 +4157,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;
@@ -4192,9 +4192,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,
--
2.25.1
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [Linux-kernel-mentees] [PATCH v2] Bluetooth: Fix memory leak in read_adv_mon_features()
2020-09-08 20:06 ` [Linux-kernel-mentees] [PATCH] Bluetooth: Fix memory leak in read_adv_mon_features() Peilin Ye
@ 2020-09-09 7:25 ` Peilin Ye
2020-09-11 7:01 ` Marcel Holtmann
0 siblings, 1 reply; 3+ messages in thread
From: Peilin Ye @ 2020-09-09 7:25 UTC (permalink / raw)
To: Marcel Holtmann, Johan Hedberg
Cc: Miao-chen Chou, syzkaller-bugs, linux-kernel, David S. Miller,
linux-bluetooth, Jakub Kicinski, linux-kernel-mentees, Peilin Ye
read_adv_mon_features() is leaking memory. Free `rp` before returning.
Fixes: e5e1e7fd470c ("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>
---
I forgot the "Link:" tag yesterday. Sorry about that.
Change in v2:
- add a proper "Link:" tag.
net/bluetooth/mgmt.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 5bbe71002fb9..f96251f818fc 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -4157,7 +4157,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;
@@ -4192,9 +4192,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,
--
2.25.1
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Linux-kernel-mentees] [PATCH v2] Bluetooth: Fix memory leak in read_adv_mon_features()
2020-09-09 7:25 ` [Linux-kernel-mentees] [PATCH v2] " Peilin Ye
@ 2020-09-11 7:01 ` Marcel Holtmann
0 siblings, 0 replies; 3+ messages in thread
From: Marcel Holtmann @ 2020-09-11 7:01 UTC (permalink / raw)
To: Peilin Ye
Cc: Miao-chen Chou, Johan Hedberg, syzkaller-bugs, open list,
linux-bluetooth, Jakub Kicinski, linux-kernel-mentees,
David S. Miller
Hi Peilin,
> read_adv_mon_features() is leaking memory. Free `rp` before returning.
>
> Fixes: e5e1e7fd470c ("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>
> ---
> I forgot the "Link:" tag yesterday. Sorry about that.
>
> Change in v2:
> - add a proper "Link:" tag.
>
> net/bluetooth/mgmt.c | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
patch has been applied to bluetooth-next tree.
Regards
Marcel
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-09-11 7:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <00000000000033913705acedbd6b@google.com>
2020-09-08 20:06 ` [Linux-kernel-mentees] [PATCH] Bluetooth: Fix memory leak in read_adv_mon_features() Peilin Ye
2020-09-09 7:25 ` [Linux-kernel-mentees] [PATCH v2] " Peilin Ye
2020-09-11 7:01 ` Marcel Holtmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).