diff mbox series

Bluetooth: vhci: manage mutex with cleanup helpers

Message ID 20240813121829.6693-1-0xff07@gmail.com (mailing list archive)
State New, archived
Headers show
Series Bluetooth: vhci: manage mutex with cleanup helpers | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch success CheckPatch PASS
tedd_an/GitLint success Gitlint PASS
tedd_an/SubjectPrefix success Gitlint PASS
tedd_an/BuildKernel success BuildKernel PASS
tedd_an/CheckAllWarning success CheckAllWarning PASS
tedd_an/CheckSparse success CheckSparse PASS
tedd_an/CheckSmatch success CheckSparse PASS
tedd_an/BuildKernel32 success BuildKernel32 PASS
tedd_an/TestRunnerSetup success TestRunnerSetup PASS
tedd_an/TestRunner_l2cap-tester success TestRunner PASS
tedd_an/TestRunner_iso-tester success TestRunner PASS
tedd_an/TestRunner_bnep-tester success TestRunner PASS
tedd_an/TestRunner_mgmt-tester success TestRunner PASS
tedd_an/TestRunner_rfcomm-tester success TestRunner PASS
tedd_an/TestRunner_sco-tester success TestRunner PASS
tedd_an/TestRunner_ioctl-tester success TestRunner PASS
tedd_an/TestRunner_mesh-tester success TestRunner PASS
tedd_an/TestRunner_smp-tester success TestRunner PASS
tedd_an/TestRunner_userchan-tester success TestRunner PASS
tedd_an/IncrementalBuild success Incremental Build PASS

Commit Message

Yo-Jung (Leo) Lin Aug. 13, 2024, 12:18 p.m. UTC
Use macros in liunx/cleanup.h for automatic resource cleanup.

Signed-off-by: Yo-Jung (Leo) Lin <0xff07@gmail.com>
---
 drivers/bluetooth/hci_vhci.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Greg Kroah-Hartman Aug. 13, 2024, 12:38 p.m. UTC | #1
On Tue, Aug 13, 2024 at 08:18:28PM +0800, Yo-Jung (Leo) Lin wrote:
> Use macros in liunx/cleanup.h for automatic resource cleanup.

That says what you do, but not _why_ you want to do it.

> 
> Signed-off-by: Yo-Jung (Leo) Lin <0xff07@gmail.com>
> ---
>  drivers/bluetooth/hci_vhci.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c
> index c4046f8f1985..70f0c28372ec 100644
> --- a/drivers/bluetooth/hci_vhci.c
> +++ b/drivers/bluetooth/hci_vhci.c
> @@ -19,6 +19,7 @@
>  #include <linux/errno.h>
>  #include <linux/sched.h>
>  #include <linux/poll.h>
> +#include <linux/cleanup.h>
>  
>  #include <linux/skbuff.h>
>  #include <linux/miscdevice.h>
> @@ -468,9 +469,9 @@ static int vhci_create_device(struct vhci_data *data, __u8 opcode)
>  {
>  	int err;
>  
> -	mutex_lock(&data->open_mutex);
> -	err = __vhci_create_device(data, opcode);
> -	mutex_unlock(&data->open_mutex);
> +	scoped_guard(mutex, &data->open_mutex) {
> +		err = __vhci_create_device(data, opcode);
> +	}

This isn't correct, but also, it's not needed at all :(

greg k-h
bluez.test.bot@gmail.com Aug. 13, 2024, 1:17 p.m. UTC | #2
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=879205

---Test result---

Test Summary:
CheckPatch                    PASS      0.61 seconds
GitLint                       PASS      0.58 seconds
SubjectPrefix                 PASS      0.11 seconds
BuildKernel                   PASS      29.42 seconds
CheckAllWarning               PASS      31.78 seconds
CheckSparse                   PASS      37.59 seconds
CheckSmatch                   PASS      103.26 seconds
BuildKernel32                 PASS      28.48 seconds
TestRunnerSetup               PASS      528.42 seconds
TestRunner_l2cap-tester       PASS      22.26 seconds
TestRunner_iso-tester         PASS      31.00 seconds
TestRunner_bnep-tester        PASS      5.00 seconds
TestRunner_mgmt-tester        PASS      110.45 seconds
TestRunner_rfcomm-tester      PASS      7.62 seconds
TestRunner_sco-tester         PASS      15.23 seconds
TestRunner_ioctl-tester       PASS      8.13 seconds
TestRunner_mesh-tester        PASS      6.13 seconds
TestRunner_smp-tester         PASS      7.04 seconds
TestRunner_userchan-tester    PASS      8.52 seconds
IncrementalBuild              PASS      28.73 seconds



---
Regards,
Linux Bluetooth
diff mbox series

Patch

diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c
index c4046f8f1985..70f0c28372ec 100644
--- a/drivers/bluetooth/hci_vhci.c
+++ b/drivers/bluetooth/hci_vhci.c
@@ -19,6 +19,7 @@ 
 #include <linux/errno.h>
 #include <linux/sched.h>
 #include <linux/poll.h>
+#include <linux/cleanup.h>
 
 #include <linux/skbuff.h>
 #include <linux/miscdevice.h>
@@ -468,9 +469,9 @@  static int vhci_create_device(struct vhci_data *data, __u8 opcode)
 {
 	int err;
 
-	mutex_lock(&data->open_mutex);
-	err = __vhci_create_device(data, opcode);
-	mutex_unlock(&data->open_mutex);
+	scoped_guard(mutex, &data->open_mutex) {
+		err = __vhci_create_device(data, opcode);
+	}
 
 	return err;
 }