linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bluetooth:Fix error checking in the function hci_disconn_complete_evt
@ 2015-08-19 14:05 Nicholas Krause
  2015-08-24  9:47 ` Johan Hedberg
  0 siblings, 1 reply; 2+ messages in thread
From: Nicholas Krause @ 2015-08-19 14:05 UTC (permalink / raw)
  To: marcel; +Cc: gustavo, johan.hedberg, davem, linux-bluetooth, netdev,
	linux-kernel

This fixes error checking in the function hci_disconn_complete_evt
to properly check if it's call to the function hci_remove_link_key
returns NULL to signal it has not correctly removed the link key
on the passed hci_dev structure pointer and if so jump to the goto
label unlock to unlock the caller's passed hci_dev structure pointer
as this function cannot continue its intended work after this failed

Signed-off-by: Nicholas Krause <xerofoify@gmail.com>
---
 net/bluetooth/hci_event.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 32363c2..5174649 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -2448,8 +2448,10 @@ static void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
 				reason, mgmt_connected);
 
 	if (conn->type == ACL_LINK) {
-		if (test_bit(HCI_CONN_FLUSH_KEY, &conn->flags))
-			hci_remove_link_key(hdev, &conn->dst);
+		if (test_bit(HCI_CONN_FLUSH_KEY, &conn->flags)) {
+			if (!hci_remove_link_key(hdev, &conn->dst))
+				goto unlock;
+		}
 
 		hci_update_page_scan(hdev);
 	}
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] bluetooth:Fix error checking in the function hci_disconn_complete_evt
  2015-08-19 14:05 [PATCH] bluetooth:Fix error checking in the function hci_disconn_complete_evt Nicholas Krause
@ 2015-08-24  9:47 ` Johan Hedberg
  0 siblings, 0 replies; 2+ messages in thread
From: Johan Hedberg @ 2015-08-24  9:47 UTC (permalink / raw)
  To: Nicholas Krause
  Cc: marcel, gustavo, davem, linux-bluetooth, netdev, linux-kernel

Hi Nicholas,

On Wed, Aug 19, 2015, Nicholas Krause wrote:
> This fixes error checking in the function hci_disconn_complete_evt
> to properly check if it's call to the function hci_remove_link_key
> returns NULL to signal it has not correctly removed the link key
> on the passed hci_dev structure pointer and if so jump to the goto
> label unlock to unlock the caller's passed hci_dev structure pointer
> as this function cannot continue its intended work after this failed
> 
> Signed-off-by: Nicholas Krause <xerofoify@gmail.com>
> ---
>  net/bluetooth/hci_event.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
> index 32363c2..5174649 100644
> --- a/net/bluetooth/hci_event.c
> +++ b/net/bluetooth/hci_event.c
> @@ -2448,8 +2448,10 @@ static void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
>  				reason, mgmt_connected);
>  
>  	if (conn->type == ACL_LINK) {
> -		if (test_bit(HCI_CONN_FLUSH_KEY, &conn->flags))
> -			hci_remove_link_key(hdev, &conn->dst);
> +		if (test_bit(HCI_CONN_FLUSH_KEY, &conn->flags)) {
> +			if (!hci_remove_link_key(hdev, &conn->dst))
> +				goto unlock;
> +		}
>  
>  		hci_update_page_scan(hdev);
>  	}

This doesn't look correct to me. The only scenario where
hci_remove_link_key() may fail is if there was no existing key (it'll
return -ENOENT then). This is a perfectly normal thing that will occur
for a disconnection of a non-paired device, so any other cleanups like
hci_update_page_scan() should still go ahead.

Johan

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-08-24  9:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-19 14:05 [PATCH] bluetooth:Fix error checking in the function hci_disconn_complete_evt Nicholas Krause
2015-08-24  9:47 ` Johan Hedberg

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).