]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
Bluetooth: msft: __hci_cmd_sync() doesn't return NULL
authorDan Carpenter <dan.carpenter@linaro.org>
Thu, 5 Oct 2023 11:19:23 +0000 (14:19 +0300)
committerSasha Levin <sashal@kernel.org>
Tue, 26 Mar 2024 22:19:38 +0000 (18:19 -0400)
commit36626c26bed6d2fe67e8a52844392d5ae7a1bc27
treed35625149ddd8069fdd3d6024d51f3a5042f2955
parenta41c8efe659caed0e21422876bbb6b73c15b5244
Bluetooth: msft: __hci_cmd_sync() doesn't return NULL

[ Upstream commit 41c56aa94c647a0f84c5c33fffb3f283e6f0e5bf ]

The __hci_cmd_sync() function doesn't return NULL.  Checking for NULL
doesn't make the code safer, it just confuses people.

When a function returns both error pointers and NULL then generally the
NULL is a kind of success case.  For example, maybe we look up an item
then errors mean we ran out of memory but NULL means the item is not
found.  Or if we request a feature, then error pointers mean that there
was an error but NULL means that the feature has been deliberately
turned off.

In this code it's different.  The NULL is handled as if there is a bug
in __hci_cmd_sync() where it accidentally returns NULL instead of a
proper error code.  This was done consistently until commit 9e14606d8f38
("Bluetooth: msft: Extended monitor tracking by address filter") which
deleted the work around for the potential future bug and treated NULL as
success.

Predicting potential future bugs is complicated, but we should just fix
them instead of working around them.  Instead of debating whether NULL
is failure or success, let's just say it's currently impossible and
delete the dead code.

Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Stable-dep-of: a6e06258f4c3 ("Bluetooth: msft: Fix memory leak")
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/bluetooth/msft.c