lkml.org 
[lkml]   [2021]   [Mar]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.14 012/176] Bluetooth: btqcomsmd: Fix a resource leak in error handling paths in the probe function
    Date
    From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

    [ Upstream commit 9a39a927be01d89e53f04304ab99a8761e08910d ]

    Some resource should be released in the error handling path of the probe
    function, as already done in the remove function.

    The remove function was fixed in commit 5052de8deff5 ("soc: qcom: smd:
    Transition client drivers from smd to rpmsg")

    Fixes: 1511cc750c3d ("Bluetooth: Introduce Qualcomm WCNSS SMD based HCI driver")
    Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
    Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    drivers/bluetooth/btqcomsmd.c | 27 +++++++++++++++++++--------
    1 file changed, 19 insertions(+), 8 deletions(-)

    diff --git a/drivers/bluetooth/btqcomsmd.c b/drivers/bluetooth/btqcomsmd.c
    index 093fd096f0c82..3a32150104c30 100644
    --- a/drivers/bluetooth/btqcomsmd.c
    +++ b/drivers/bluetooth/btqcomsmd.c
    @@ -154,12 +154,16 @@ static int btqcomsmd_probe(struct platform_device *pdev)

    btq->cmd_channel = qcom_wcnss_open_channel(wcnss, "APPS_RIVA_BT_CMD",
    btqcomsmd_cmd_callback, btq);
    - if (IS_ERR(btq->cmd_channel))
    - return PTR_ERR(btq->cmd_channel);
    + if (IS_ERR(btq->cmd_channel)) {
    + ret = PTR_ERR(btq->cmd_channel);
    + goto destroy_acl_channel;
    + }

    hdev = hci_alloc_dev();
    - if (!hdev)
    - return -ENOMEM;
    + if (!hdev) {
    + ret = -ENOMEM;
    + goto destroy_cmd_channel;
    + }

    hci_set_drvdata(hdev, btq);
    btq->hdev = hdev;
    @@ -173,14 +177,21 @@ static int btqcomsmd_probe(struct platform_device *pdev)
    hdev->set_bdaddr = qca_set_bdaddr_rome;

    ret = hci_register_dev(hdev);
    - if (ret < 0) {
    - hci_free_dev(hdev);
    - return ret;
    - }
    + if (ret < 0)
    + goto hci_free_dev;

    platform_set_drvdata(pdev, btq);

    return 0;
    +
    +hci_free_dev:
    + hci_free_dev(hdev);
    +destroy_cmd_channel:
    + rpmsg_destroy_ept(btq->cmd_channel);
    +destroy_acl_channel:
    + rpmsg_destroy_ept(btq->acl_channel);
    +
    + return ret;
    }

    static int btqcomsmd_remove(struct platform_device *pdev)
    --
    2.27.0


    \
     
     \ /
      Last update: 2021-03-01 19:25    [W:4.895 / U:0.020 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site