Re: [PATCH] Bluetooth: hci_core: fix error handling in hci_register_dev()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Wed, Oct 19, 2022 at 12:31 AM Yang Yingliang
<yangyingliang@xxxxxxxxxx> wrote:
>
> If hci_register_suspend_notifier() returns error, the hdev
> need to be put and deleted and rfkill need be unregistered
> to avoid leaks.
>
> Fixes: 9952d90ea288 ("Bluetooth: Handle PM_SUSPEND_PREPARE and PM_POST_SUSPEND")
> Signed-off-by: Yang Yingliang <yangyingliang@xxxxxxxxxx>
> ---
>  net/bluetooth/hci_core.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
> index 0540555b3704..03b9374f3a97 100644
> --- a/net/bluetooth/hci_core.c
> +++ b/net/bluetooth/hci_core.c
> @@ -2660,7 +2660,7 @@ int hci_register_dev(struct hci_dev *hdev)
>
>         error = hci_register_suspend_notifier(hdev);
>         if (error)
> -               goto err_wqueue;
> +               goto err_hdev;

Perhaps we could disregard the error here, or print a warning, as it
just means we won't be handing suspend requests which I guess is
better than having to fail to register which would render the
controller useless.

>
>         queue_work(hdev->req_workqueue, &hdev->power_on);
>
> @@ -2669,6 +2669,11 @@ int hci_register_dev(struct hci_dev *hdev)
>
>         return id;
>
> +err_hdev:
> +       hci_dev_put(hdev);
> +       if (hdev->rfkill)
> +               rfkill_unregister(hdev->rfkill);
> +       device_del(&hdev->dev);
>  err_wqueue:
>         debugfs_remove_recursive(hdev->debugfs);
>         destroy_workqueue(hdev->workqueue);
> --
> 2.25.1
>


-- 
Luiz Augusto von Dentz



[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux