Message ID | 20221108112308.3910185-1-bobo.shaobowang@huawei.com (mailing list archive) |
---|---|
State | Awaiting Upstream |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | Bluetooth: hci_conn: Fix potential memleak in iso_listen_bis() | expand |
Hi Wang, On Tue, Nov 8, 2022 at 3:24 AM Wang ShaoBo <bobo.shaobowang@huawei.com> wrote: > > When hci_pa_create_sync() failed, hdev should be freed as there > was no place to handle its recycling after. The patch itself seems fine but the description is misleading since we are not freeing the hdev instead we are jus releasing the reference we got. > Fixes: f764a6c2c1e4 ("Bluetooth: ISO: Add broadcast support") > Signed-off-by: Wang ShaoBo <bobo.shaobowang@huawei.com> > --- > net/bluetooth/iso.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/net/bluetooth/iso.c b/net/bluetooth/iso.c > index f825857db6d0..4e3867110dc1 100644 > --- a/net/bluetooth/iso.c > +++ b/net/bluetooth/iso.c > @@ -880,6 +880,9 @@ static int iso_listen_bis(struct sock *sk) > > hci_dev_unlock(hdev); > > + if (err) > + hci_dev_put(hdev); Not sure why you are not always calling hci_dev_put? > return err; > } > > -- > 2.25.1 >
在 2022/11/9 7:41, Luiz Augusto von Dentz 写道: > Hi Wang, > > On Tue, Nov 8, 2022 at 3:24 AM Wang ShaoBo <bobo.shaobowang@huawei.com> wrote: >> When hci_pa_create_sync() failed, hdev should be freed as there >> was no place to handle its recycling after. > The patch itself seems fine but the description is misleading since we > are not freeing the hdev instead we are jus releasing the reference we > got. > >> Fixes: f764a6c2c1e4 ("Bluetooth: ISO: Add broadcast support") >> Signed-off-by: Wang ShaoBo <bobo.shaobowang@huawei.com> >> --- >> net/bluetooth/iso.c | 3 +++ >> 1 file changed, 3 insertions(+) >> >> diff --git a/net/bluetooth/iso.c b/net/bluetooth/iso.c >> index f825857db6d0..4e3867110dc1 100644 >> --- a/net/bluetooth/iso.c >> +++ b/net/bluetooth/iso.c >> @@ -880,6 +880,9 @@ static int iso_listen_bis(struct sock *sk) >> >> hci_dev_unlock(hdev); >> >> + if (err) >> + hci_dev_put(hdev); > Not sure why you are not always calling hci_dev_put? emm, I would have thought that the reference would be released after calling hci_cmd_sync_queue(), but in fact actually not. -- Wang ShaoBo > >> return err; >> } >> >> -- >> 2.25.1 >> >
diff --git a/net/bluetooth/iso.c b/net/bluetooth/iso.c index f825857db6d0..4e3867110dc1 100644 --- a/net/bluetooth/iso.c +++ b/net/bluetooth/iso.c @@ -880,6 +880,9 @@ static int iso_listen_bis(struct sock *sk) hci_dev_unlock(hdev); + if (err) + hci_dev_put(hdev); + return err; }
When hci_pa_create_sync() failed, hdev should be freed as there was no place to handle its recycling after. Fixes: f764a6c2c1e4 ("Bluetooth: ISO: Add broadcast support") Signed-off-by: Wang ShaoBo <bobo.shaobowang@huawei.com> --- net/bluetooth/iso.c | 3 +++ 1 file changed, 3 insertions(+)