* [PATCH] Bluetooth: Fix potential memory leak
@ 2017-10-24 7:29 Jaganath Kanakkassery
2017-10-24 7:41 ` Marcel Holtmann
0 siblings, 1 reply; 5+ messages in thread
From: Jaganath Kanakkassery @ 2017-10-24 7:29 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jaganath Kanakkassery
If command is added to req then it should be freed in case if
hdev is down or HCI_ADVERTISING flag is not set.
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
---
net/bluetooth/mgmt.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 1fba2a0..58045ee 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -6383,6 +6383,7 @@ static int remove_advertising(struct sock *sk, struct hci_dev *hdev,
if (skb_queue_empty(&req.cmd_q) ||
!hdev_is_powered(hdev) ||
hci_dev_test_flag(hdev, HCI_ADVERTISING)) {
+ skb_queue_purge(&req.cmd_q);
rp.instance = cp->instance;
err = mgmt_cmd_complete(sk, hdev->id,
MGMT_OP_REMOVE_ADVERTISING,
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] Bluetooth: Fix potential memory leak
2017-10-24 7:29 [PATCH] Bluetooth: Fix potential memory leak Jaganath Kanakkassery
@ 2017-10-24 7:41 ` Marcel Holtmann
2017-10-24 8:58 ` Johan Hedberg
0 siblings, 1 reply; 5+ messages in thread
From: Marcel Holtmann @ 2017-10-24 7:41 UTC (permalink / raw)
To: Jaganath Kanakkassery; +Cc: open list:BLUETOOTH DRIVERS, Jaganath Kanakkassery
Hi Jaganath,
> If command is added to req then it should be freed in case if
> hdev is down or HCI_ADVERTISING flag is not set.
>
> Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
> ---
> net/bluetooth/mgmt.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
> index 1fba2a0..58045ee 100644
> --- a/net/bluetooth/mgmt.c
> +++ b/net/bluetooth/mgmt.c
> @@ -6383,6 +6383,7 @@ static int remove_advertising(struct sock *sk, struct hci_dev *hdev,
> if (skb_queue_empty(&req.cmd_q) ||
> !hdev_is_powered(hdev) ||
> hci_dev_test_flag(hdev, HCI_ADVERTISING)) {
> + skb_queue_purge(&req.cmd_q);
> rp.instance = cp->instance;
> err = mgmt_cmd_complete(sk, hdev->id,
> MGMT_OP_REMOVE_ADVERTISING,
this does not look right to me. It most likely has side affects. The fix must be differently if there is a memory leak.
Regards
Marcel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Bluetooth: Fix potential memory leak
2017-10-24 7:41 ` Marcel Holtmann
@ 2017-10-24 8:58 ` Johan Hedberg
2017-10-24 12:43 ` Marcel Holtmann
0 siblings, 1 reply; 5+ messages in thread
From: Johan Hedberg @ 2017-10-24 8:58 UTC (permalink / raw)
To: Marcel Holtmann
Cc: Jaganath Kanakkassery, open list:BLUETOOTH DRIVERS,
Jaganath Kanakkassery
Hi Marcel,
On Tue, Oct 24, 2017, Marcel Holtmann wrote:
> > index 1fba2a0..58045ee 100644
> > --- a/net/bluetooth/mgmt.c
> > +++ b/net/bluetooth/mgmt.c
> > @@ -6383,6 +6383,7 @@ static int remove_advertising(struct sock *sk, struct hci_dev *hdev,
> > if (skb_queue_empty(&req.cmd_q) ||
> > !hdev_is_powered(hdev) ||
> > hci_dev_test_flag(hdev, HCI_ADVERTISING)) {
> > + skb_queue_purge(&req.cmd_q);
> > rp.instance = cp->instance;
> > err = mgmt_cmd_complete(sk, hdev->id,
> > MGMT_OP_REMOVE_ADVERTISING,
>
> this does not look right to me. It most likely has side affects. The
> fix must be differently if there is a memory leak.
Actually, it looks like the right fix to me. We don't have a separate
helper to clean up a hci_request that never got used, and
skb_queue_purge is what other places in the code seem to be doing in
this kind of cases.
Johan
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Bluetooth: Fix potential memory leak
2017-10-24 8:58 ` Johan Hedberg
@ 2017-10-24 12:43 ` Marcel Holtmann
2017-10-25 5:44 ` Jaganath K
0 siblings, 1 reply; 5+ messages in thread
From: Marcel Holtmann @ 2017-10-24 12:43 UTC (permalink / raw)
To: Johan Hedberg
Cc: Jaganath Kanakkassery, open list:BLUETOOTH DRIVERS,
Jaganath Kanakkassery
Hi Johan,
>>> index 1fba2a0..58045ee 100644
>>> --- a/net/bluetooth/mgmt.c
>>> +++ b/net/bluetooth/mgmt.c
>>> @@ -6383,6 +6383,7 @@ static int remove_advertising(struct sock *sk, struct hci_dev *hdev,
>>> if (skb_queue_empty(&req.cmd_q) ||
>>> !hdev_is_powered(hdev) ||
>>> hci_dev_test_flag(hdev, HCI_ADVERTISING)) {
>>> + skb_queue_purge(&req.cmd_q);
>>> rp.instance = cp->instance;
>>> err = mgmt_cmd_complete(sk, hdev->id,
>>> MGMT_OP_REMOVE_ADVERTISING,
>>
>> this does not look right to me. It most likely has side affects. The
>> fix must be differently if there is a memory leak.
>
> Actually, it looks like the right fix to me. We don't have a separate
> helper to clean up a hci_request that never got used, and
> skb_queue_purge is what other places in the code seem to be doing in
> this kind of cases.
then we need a helper to do this. This is pretty bad style if we hook into the queue directly with a skb_queue_purge. Since that cmd_q should be a hidden detail.
Regards
Marcel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Bluetooth: Fix potential memory leak
2017-10-24 12:43 ` Marcel Holtmann
@ 2017-10-25 5:44 ` Jaganath K
0 siblings, 0 replies; 5+ messages in thread
From: Jaganath K @ 2017-10-25 5:44 UTC (permalink / raw)
To: Marcel Holtmann
Cc: Johan Hedberg, open list:BLUETOOTH DRIVERS, Jaganath Kanakkassery
Hi Marcel, Johan,
On Tue, Oct 24, 2017 at 6:13 PM, Marcel Holtmann <marcel@holtmann.org> wrote:
> Hi Johan,
>
>>>> index 1fba2a0..58045ee 100644
>>>> --- a/net/bluetooth/mgmt.c
>>>> +++ b/net/bluetooth/mgmt.c
>>>> @@ -6383,6 +6383,7 @@ static int remove_advertising(struct sock *sk, struct hci_dev *hdev,
>>>> if (skb_queue_empty(&req.cmd_q) ||
>>>> !hdev_is_powered(hdev) ||
>>>> hci_dev_test_flag(hdev, HCI_ADVERTISING)) {
>>>> + skb_queue_purge(&req.cmd_q);
>>>> rp.instance = cp->instance;
>>>> err = mgmt_cmd_complete(sk, hdev->id,
>>>> MGMT_OP_REMOVE_ADVERTISING,
>>>
>>> this does not look right to me. It most likely has side affects. The
>>> fix must be differently if there is a memory leak.
>>
>> Actually, it looks like the right fix to me. We don't have a separate
>> helper to clean up a hci_request that never got used, and
>> skb_queue_purge is what other places in the code seem to be doing in
>> this kind of cases.
>
> then we need a helper to do this. This is pretty bad style if we hook into the queue directly with a skb_queue_purge. Since that cmd_q should be a hidden detail.
I have raised v1 with the suggested changes.
Thanks,
Jaganath
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-10-25 5:44 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-24 7:29 [PATCH] Bluetooth: Fix potential memory leak Jaganath Kanakkassery
2017-10-24 7:41 ` Marcel Holtmann
2017-10-24 8:58 ` Johan Hedberg
2017-10-24 12:43 ` Marcel Holtmann
2017-10-25 5:44 ` Jaganath K
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.