linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [BlueZ PATCH v2] device: Fix crash when removing device
@ 2022-02-10 22:55 Luiz Augusto von Dentz
  2022-02-10 23:56 ` Tedd Ho-Jeong An
  2022-02-11  0:23 ` [BlueZ,v2] " bluez.test.bot
  0 siblings, 2 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2022-02-10 22:55 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

Calling btd_adapter_remove_device from device_remove_connection can
cause a crash, so instead of removing it immediatelly this set a the
temporary timeout to 0.

Fixes: https://github.com/bluez/bluez/issues/290
---
v2: Fix compilation

 src/device.c | 46 +++++++++++++++++++++++-----------------------
 1 file changed, 23 insertions(+), 23 deletions(-)

diff --git a/src/device.c b/src/device.c
index 6d29eb896..81b8ebd1e 100644
--- a/src/device.c
+++ b/src/device.c
@@ -3200,6 +3200,28 @@ void device_add_connection(struct btd_device *dev, uint8_t bdaddr_type)
 								"Connected");
 }
 
+static bool device_disappeared(gpointer user_data)
+{
+	struct btd_device *dev = user_data;
+
+	dev->temporary_timer = 0;
+
+	btd_adapter_remove_device(dev->adapter, dev);
+
+	return FALSE;
+}
+
+static void set_temporary_timer(struct btd_device *dev, unsigned int timeout)
+{
+	clear_temporary_timer(dev);
+
+	if (!timeout)
+		return;
+
+	dev->temporary_timer = timeout_add_seconds(timeout, device_disappeared,
+								dev, NULL);
+}
+
 void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type)
 {
 	struct bearer_state *state = get_state(device, bdaddr_type);
@@ -3285,7 +3307,7 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type)
 						DEVICE_INTERFACE, "Connected");
 
 	if (remove_device)
-		btd_adapter_remove_device(device->adapter, device);
+		set_temporary_timer(device, 0);
 }
 
 guint device_add_disconnect_watch(struct btd_device *device,
@@ -4590,28 +4612,6 @@ void device_set_le_support(struct btd_device *device, uint8_t bdaddr_type)
 	store_device_info(device);
 }
 
-static bool device_disappeared(gpointer user_data)
-{
-	struct btd_device *dev = user_data;
-
-	dev->temporary_timer = 0;
-
-	btd_adapter_remove_device(dev->adapter, dev);
-
-	return FALSE;
-}
-
-static void set_temporary_timer(struct btd_device *dev, unsigned int timeout)
-{
-	clear_temporary_timer(dev);
-
-	if (!timeout)
-		return;
-
-	dev->temporary_timer = timeout_add_seconds(timeout, device_disappeared,
-								dev, NULL);
-}
-
 void device_update_last_seen(struct btd_device *device, uint8_t bdaddr_type)
 {
 	if (bdaddr_type == BDADDR_BREDR)
-- 
2.34.1


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

* Re: [BlueZ PATCH v2] device: Fix crash when removing device
  2022-02-10 22:55 [BlueZ PATCH v2] device: Fix crash when removing device Luiz Augusto von Dentz
@ 2022-02-10 23:56 ` Tedd Ho-Jeong An
  2022-02-11  0:23 ` [BlueZ,v2] " bluez.test.bot
  1 sibling, 0 replies; 4+ messages in thread
From: Tedd Ho-Jeong An @ 2022-02-10 23:56 UTC (permalink / raw)
  To: Luiz Augusto von Dentz, linux-bluetooth

On Thu, 2022-02-10 at 14:55 -0800, Luiz Augusto von Dentz wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> 
> Calling btd_adapter_remove_device from device_remove_connection can
> cause a crash, so instead of removing it immediatelly this set a the
> temporary timeout to 0.
> 
> Fixes: https://github.com/bluez/bluez/issues/290

Tested-by: Tedd Ho-Jeong AN <tedd.an@intel.com>

> ---
> v2: Fix compilation
> 
>  src/device.c | 46 +++++++++++++++++++++++-----------------------
>  1 file changed, 23 insertions(+), 23 deletions(-)
> 
> diff --git a/src/device.c b/src/device.c
> index 6d29eb896..81b8ebd1e 100644
> --- a/src/device.c
> +++ b/src/device.c
> @@ -3200,6 +3200,28 @@ void device_add_connection(struct btd_device *dev, uint8_t bdaddr_type)
>                                                                 "Connected");
>  }
>  
> +static bool device_disappeared(gpointer user_data)
> +{
> +       struct btd_device *dev = user_data;
> +
> +       dev->temporary_timer = 0;
> +
> +       btd_adapter_remove_device(dev->adapter, dev);
> +
> +       return FALSE;
> +}
> +
> +static void set_temporary_timer(struct btd_device *dev, unsigned int timeout)
> +{
> +       clear_temporary_timer(dev);
> +
> +       if (!timeout)
> +               return;
> +
> +       dev->temporary_timer = timeout_add_seconds(timeout, device_disappeared,
> +                                                               dev, NULL);
> +}
> +
>  void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type)
>  {
>         struct bearer_state *state = get_state(device, bdaddr_type);
> @@ -3285,7 +3307,7 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type)
>                                                 DEVICE_INTERFACE, "Connected");
>  
>         if (remove_device)
> -               btd_adapter_remove_device(device->adapter, device);
> +               set_temporary_timer(device, 0);
>  }
>  
>  guint device_add_disconnect_watch(struct btd_device *device,
> @@ -4590,28 +4612,6 @@ void device_set_le_support(struct btd_device *device, uint8_t bdaddr_type)
>         store_device_info(device);
>  }
>  
> -static bool device_disappeared(gpointer user_data)
> -{
> -       struct btd_device *dev = user_data;
> -
> -       dev->temporary_timer = 0;
> -
> -       btd_adapter_remove_device(dev->adapter, dev);
> -
> -       return FALSE;
> -}
> -
> -static void set_temporary_timer(struct btd_device *dev, unsigned int timeout)
> -{
> -       clear_temporary_timer(dev);
> -
> -       if (!timeout)
> -               return;
> -
> -       dev->temporary_timer = timeout_add_seconds(timeout, device_disappeared,
> -                                                               dev, NULL);
> -}
> -
>  void device_update_last_seen(struct btd_device *device, uint8_t bdaddr_type)
>  {
>         if (bdaddr_type == BDADDR_BREDR)



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

* RE: [BlueZ,v2] device: Fix crash when removing device
  2022-02-10 22:55 [BlueZ PATCH v2] device: Fix crash when removing device Luiz Augusto von Dentz
  2022-02-10 23:56 ` Tedd Ho-Jeong An
@ 2022-02-11  0:23 ` bluez.test.bot
  2022-02-11 22:20   ` Luiz Augusto von Dentz
  1 sibling, 1 reply; 4+ messages in thread
From: bluez.test.bot @ 2022-02-11  0:23 UTC (permalink / raw)
  To: linux-bluetooth, luiz.dentz

[-- Attachment #1: Type: text/plain, Size: 1983 bytes --]

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=613256

---Test result---

Test Summary:
CheckPatch                    FAIL      1.46 seconds
GitLint                       PASS      1.00 seconds
Prep - Setup ELL              PASS      41.27 seconds
Build - Prep                  PASS      0.75 seconds
Build - Configure             PASS      8.25 seconds
Build - Make                  PASS      1386.15 seconds
Make Check                    PASS      11.95 seconds
Make Check w/Valgrind         PASS      440.83 seconds
Make Distcheck                PASS      230.47 seconds
Build w/ext ELL - Configure   PASS      8.17 seconds
Build w/ext ELL - Make        PASS      1374.80 seconds
Incremental Build with patchesPASS      0.00 seconds

Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script with rule in .checkpatch.conf
Output:
[BlueZ,v2] device: Fix crash when removing device
WARNING:TYPO_SPELLING: 'immediatelly' may be misspelled - perhaps 'immediately'?
#81: 
cause a crash, so instead of removing it immediatelly this set a the
                                         ^^^^^^^^^^^^

/github/workspace/src/12742555.patch total: 0 errors, 1 warnings, 64 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

/github/workspace/src/12742555.patch has style problems, please review.

NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.




---
Regards,
Linux Bluetooth


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

* Re: [BlueZ,v2] device: Fix crash when removing device
  2022-02-11  0:23 ` [BlueZ,v2] " bluez.test.bot
@ 2022-02-11 22:20   ` Luiz Augusto von Dentz
  0 siblings, 0 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2022-02-11 22:20 UTC (permalink / raw)
  To: linux-bluetooth

Hi,

On Thu, Feb 10, 2022 at 4:23 PM <bluez.test.bot@gmail.com> wrote:
>
> This is automated email and please do not reply to this email!
>
> Dear submitter,
>
> Thank you for submitting the patches to the linux bluetooth mailing list.
> This is a CI test results with your patch series:
> PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=613256
>
> ---Test result---
>
> Test Summary:
> CheckPatch                    FAIL      1.46 seconds
> GitLint                       PASS      1.00 seconds
> Prep - Setup ELL              PASS      41.27 seconds
> Build - Prep                  PASS      0.75 seconds
> Build - Configure             PASS      8.25 seconds
> Build - Make                  PASS      1386.15 seconds
> Make Check                    PASS      11.95 seconds
> Make Check w/Valgrind         PASS      440.83 seconds
> Make Distcheck                PASS      230.47 seconds
> Build w/ext ELL - Configure   PASS      8.17 seconds
> Build w/ext ELL - Make        PASS      1374.80 seconds
> Incremental Build with patchesPASS      0.00 seconds
>
> Details
> ##############################
> Test: CheckPatch - FAIL
> Desc: Run checkpatch.pl script with rule in .checkpatch.conf
> Output:
> [BlueZ,v2] device: Fix crash when removing device
> WARNING:TYPO_SPELLING: 'immediatelly' may be misspelled - perhaps 'immediately'?
> #81:
> cause a crash, so instead of removing it immediatelly this set a the
>                                          ^^^^^^^^^^^^
>
> /github/workspace/src/12742555.patch total: 0 errors, 1 warnings, 64 lines checked
>
> NOTE: For some of the reported defects, checkpatch may be able to
>       mechanically convert to the typical style using --fix or --fix-inplace.
>
> /github/workspace/src/12742555.patch has style problems, please review.
>
> NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO
>
> NOTE: If any of the errors are false positives, please report
>       them to the maintainer, see CHECKPATCH in MAINTAINERS.
>
>
>
>
> ---
> Regards,
> Linux Bluetooth

Pushed.

-- 
Luiz Augusto von Dentz

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

end of thread, other threads:[~2022-02-11 22:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-10 22:55 [BlueZ PATCH v2] device: Fix crash when removing device Luiz Augusto von Dentz
2022-02-10 23:56 ` Tedd Ho-Jeong An
2022-02-11  0:23 ` [BlueZ,v2] " bluez.test.bot
2022-02-11 22:20   ` Luiz Augusto von Dentz

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