diff mbox series

[BlueZ,v2] plugins/sixaxis: add NULL check in setup_device()

Message ID 20240627123935.67784-1-r.smirnov@omp.ru (mailing list archive)
State Accepted
Commit e3616b776ae0d50c94807ed970cb724518b8a47e
Headers show
Series [BlueZ,v2] plugins/sixaxis: add NULL check in setup_device() | 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/BuildEll success Build ELL PASS
tedd_an/BluezMake success Bluez Make PASS
tedd_an/MakeCheck success Bluez Make Check PASS
tedd_an/MakeDistcheck success Make Distcheck PASS
tedd_an/CheckValgrind success Check Valgrind PASS
tedd_an/CheckSmatch success CheckSparse PASS
tedd_an/bluezmakeextell success Make External ELL PASS
tedd_an/IncrementalBuild success Incremental Build PASS
tedd_an/ScanBuild success Scan Build PASS

Commit Message

Roman Smirnov June 27, 2024, 12:39 p.m. UTC
btd_adapter_get_device() may return NULL on the next call stack:

btd_adapter_get_device()
    adapter_create_device()
        device_create()
            device_new()
                g_try_malloc0()

It is necessary to prevent this to avoid dereferencing a null
pointer further.
---
 plugins/sixaxis.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

bluez.test.bot@gmail.com June 27, 2024, 2:18 p.m. UTC | #1
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=866143

---Test result---

Test Summary:
CheckPatch                    PASS      0.44 seconds
GitLint                       PASS      0.31 seconds
BuildEll                      PASS      24.69 seconds
BluezMake                     PASS      1672.82 seconds
MakeCheck                     PASS      13.57 seconds
MakeDistcheck                 PASS      178.25 seconds
CheckValgrind                 PASS      253.30 seconds
CheckSmatch                   PASS      355.08 seconds
bluezmakeextell               PASS      120.44 seconds
IncrementalBuild              PASS      1448.99 seconds
ScanBuild                     PASS      1009.64 seconds



---
Regards,
Linux Bluetooth
patchwork-bot+bluetooth@kernel.org June 27, 2024, 6:40 p.m. UTC | #2
Hello:

This patch was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Thu, 27 Jun 2024 15:39:02 +0300 you wrote:
> btd_adapter_get_device() may return NULL on the next call stack:
> 
> btd_adapter_get_device()
>     adapter_create_device()
>         device_create()
>             device_new()
>                 g_try_malloc0()
> 
> [...]

Here is the summary with links:
  - [BlueZ,v2] plugins/sixaxis: add NULL check in setup_device()
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=e3616b776ae0

You are awesome, thank you!
diff mbox series

Patch

diff --git a/plugins/sixaxis.c b/plugins/sixaxis.c
index 544ab399a..3e69f1dd2 100644
--- a/plugins/sixaxis.c
+++ b/plugins/sixaxis.c
@@ -346,6 +346,11 @@  static bool setup_device(int fd, const char *sysfs_path,
 
 	device = btd_adapter_get_device(adapter, &device_bdaddr, BDADDR_BREDR);
 
+	if (!device) {
+		error("sixaxis: unable to set up a new device");
+		return false;
+	}
+
 	info("sixaxis: setting up new device");
 
 	btd_device_device_set_name(device, cp->name);