Bluetooth: hci_qca: Fix NULL vs IS_ERR_OR_NULL check in qca_serdev_probe
authorMiaoqian Lin <linmq006@gmail.com>
Fri, 24 Dec 2021 08:02:49 +0000 (08:02 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 27 Jan 2022 09:54:01 +0000 (10:54 +0100)
[ Upstream commit 6845667146a28c09b5dfc401c1ad112374087944 ]

The function devm_gpiod_get_index() return error pointers on error.
Thus devm_gpiod_get_index_optional() could return NULL and error pointers.
The same as devm_gpiod_get_optional() function. Using IS_ERR_OR_NULL()
check to catch error pointers.

Fixes: 77131dfe ("Bluetooth: hci_qca: Replace devm_gpiod_get() with devm_gpiod_get_optional()")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/bluetooth/hci_qca.c

index 4f8a32601c1b651c1a1a0ff25d1e8ca1ad8b66ac..dc7ee5dd2eeca3f15685ea97ba85e8396a3f77c4 100644 (file)
@@ -1990,7 +1990,7 @@ static int qca_serdev_probe(struct serdev_device *serdev)
 
                qcadev->bt_en = devm_gpiod_get_optional(&serdev->dev, "enable",
                                               GPIOD_OUT_LOW);
-               if (!qcadev->bt_en) {
+               if (IS_ERR_OR_NULL(qcadev->bt_en)) {
                        dev_warn(&serdev->dev, "failed to acquire enable gpio\n");
                        power_ctrl_enabled = false;
                }