Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp377831pxb; Wed, 3 Mar 2021 05:42:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJy32DeAU3PD0G792uFNUwKc5jeT44sC5VQgeFRYQnIoh7NsZBhsYg9L5nWK0R7VrL1VgXwJ X-Received: by 2002:a17:906:c181:: with SMTP id g1mr25021473ejz.96.1614778975836; Wed, 03 Mar 2021 05:42:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614778975; cv=none; d=google.com; s=arc-20160816; b=hoQPqwYz9mr72DQ9CFtVw7kRJ0YoQ5eW5Q+PvnjrveqB/kVnQr+2Bk6lhTDE0FkN8R OKDom8JDJAPDsWjDTUZCAyPrn8NPrE0jQrnYThG0kt+jxpW1shK20sI+A/8E3GveAmCF KxCdSikMbomxPlltSXhClsCC1YphK90D2cdtJ6WIGjef/+5W9i30lCgXjGYW49UC54MA LJ+I4hJ6C7pvePsusnAVgK1VX4tZJwmcsLBsSpk7JtdbAAXIa1swqx3dtqOB2OW457sZ GzZjXiaPVlXweImPUf8k24GCdNvlg5NUhJXpQuRxH6lazUGQv0BTP69rJ73Teh675bH7 49wQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=UrrDSRBrz5L2TKuQoo9pmuhRsPqPUBkYa6FMT0bcOiE=; b=tGYp9Q34iG3JIWN3q3z5Hd0cewij+Gl2BSk8SHO/f5rCzJamYE4OyYBi2Oa/pa5zYv v2nyhb5e8oo7phtQozplCd2e3fU+wzTuUIv3bJ/ZJWQvIssOynjU3p6/EnQZi3JuitVt cih4+vVc1Juz1OTvr7BKeNCfUbN+FFsJfdwnvkwMHpwrmLwBhqkhA9X18DpMUN+DfeK8 WsMiW50nMPMclY48fNA9z/m5b7U4M9a58bR1RuJC+tBqXpsxk1ydOA14+jXVdBsj5utM 20I5y0rXE/MlyBEe9NTWC+T+mv5EKUC0czcs9EhB49k/YEHI45RmlMgC2gkB3I4XlXNU v2nQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Ni+s8z/s"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r21si15488271ejo.142.2021.03.03.05.42.18; Wed, 03 Mar 2021 05:42:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Ni+s8z/s"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242516AbhCATxt (ORCPT + 99 others); Mon, 1 Mar 2021 14:53:49 -0500 Received: from mail.kernel.org ([198.145.29.99]:59164 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236266AbhCAQ6K (ORCPT ); Mon, 1 Mar 2021 11:58:10 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8277964F56; Mon, 1 Mar 2021 16:36:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614616606; bh=3M0jd727EZrJt6Mej086pr9TOogq2S9wLhEjBjIHrG8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ni+s8z/si3hniV6Ri/QolCDLzCf0txrjpvublRGb1+YVWUadf7j7I6ReyIO4jGn8/ IVXP8gGxMWLk9TWsMWj3CynZIqpJn2kI+GJbPJ8ACYYknrl3pL9qSRRTkESENH8uDq jFUpQRagEX0IWMLY8u96Cur3NPnfIK8PeUxYFMEI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe JAILLET , Marcel Holtmann , Sasha Levin Subject: [PATCH 4.19 025/247] Bluetooth: btqcomsmd: Fix a resource leak in error handling paths in the probe function Date: Mon, 1 Mar 2021 17:10:45 +0100 Message-Id: <20210301161032.926097781@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161031.684018251@linuxfoundation.org> References: <20210301161031.684018251@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christophe JAILLET [ 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 Signed-off-by: Marcel Holtmann Signed-off-by: Sasha Levin --- 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 7df3eed1ef5e9..874172aa8e417 100644 --- a/drivers/bluetooth/btqcomsmd.c +++ b/drivers/bluetooth/btqcomsmd.c @@ -166,8 +166,10 @@ 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; + } /* The local-bd-address property is usually injected by the * bootloader which has access to the allocated BD address. @@ -179,8 +181,10 @@ static int btqcomsmd_probe(struct platform_device *pdev) } hdev = hci_alloc_dev(); - if (!hdev) - return -ENOMEM; + if (!hdev) { + ret = -ENOMEM; + goto destroy_cmd_channel; + } hci_set_drvdata(hdev, btq); btq->hdev = hdev; @@ -194,14 +198,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