Commit 32b9ccbc authored by Loic Poulain's avatar Loic Poulain Committed by Marcel Holtmann

Bluetooth: hci_intel: Fix null gpio desc pointer dereference

gpiod_get_optional can return either ERR_PTR or NULL pointer.
NULL case is not tested and then dereferenced later in desc_to_gpio.
Fix this by using non optional version which returns ERR_PTR in any
error case (this is not an optional gpio).
Use the same non optional version for the host-wake gpio.

Fixes: 765ea3ab ("Bluetooth: hci_intel: Retrieve host-wake IRQ")
Signed-off-by: default avatarLoic Poulain <loic.poulain@intel.com>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent bb7f4f0b
...@@ -1210,8 +1210,7 @@ static int intel_probe(struct platform_device *pdev) ...@@ -1210,8 +1210,7 @@ static int intel_probe(struct platform_device *pdev)
idev->pdev = pdev; idev->pdev = pdev;
idev->reset = devm_gpiod_get_optional(&pdev->dev, "reset", idev->reset = devm_gpiod_get(&pdev->dev, "reset", GPIOD_OUT_LOW);
GPIOD_OUT_LOW);
if (IS_ERR(idev->reset)) { if (IS_ERR(idev->reset)) {
dev_err(&pdev->dev, "Unable to retrieve gpio\n"); dev_err(&pdev->dev, "Unable to retrieve gpio\n");
return PTR_ERR(idev->reset); return PTR_ERR(idev->reset);
...@@ -1223,8 +1222,7 @@ static int intel_probe(struct platform_device *pdev) ...@@ -1223,8 +1222,7 @@ static int intel_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "No IRQ, falling back to gpio-irq\n"); dev_err(&pdev->dev, "No IRQ, falling back to gpio-irq\n");
host_wake = devm_gpiod_get_optional(&pdev->dev, "host-wake", host_wake = devm_gpiod_get(&pdev->dev, "host-wake", GPIOD_IN);
GPIOD_IN);
if (IS_ERR(host_wake)) { if (IS_ERR(host_wake)) {
dev_err(&pdev->dev, "Unable to retrieve IRQ\n"); dev_err(&pdev->dev, "Unable to retrieve IRQ\n");
goto no_irq; goto no_irq;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment