Received: by 2002:a4a:311b:0:0:0:0:0 with SMTP id k27-v6csp4873443ooa; Tue, 14 Aug 2018 11:46:38 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzTwR9SSUaxq05pNehcObg5FGeS6oAnmf3jZY5Sd3dtj+x63YA+9mGp2xYpc+Hu7PSQjpVK X-Received: by 2002:a17:902:a983:: with SMTP id bh3-v6mr21891858plb.245.1534272398379; Tue, 14 Aug 2018 11:46:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534272398; cv=none; d=google.com; s=arc-20160816; b=FprNJ97wGXSj8Z/hX3zbMx/Utq0o/WVQQDwGNwNs+/LbXaAva2Al8TmaC+JvjRWIHr DEfk1KXwCm6qEFQ+1ny9uzT/m7563q/Rll/4XSuszHKzx/iS1YfuneAiAwvuBgZ5bjRU jHesq0S4GePVgAh6jd7SOJTPtMfCklTy4D6P4kOwQ2Xr/Q8OzDKFBOwSaM+kpKJtP7Yu znb6Er5jV7it5KXUrwBj9Dtml8s7oRRBlvrmNqe7eG1WVQw95su0fjOsaMm0w1E4Ahjq O4qZSu2FRoZU/4pTjzpxUe/wKyFEBFUTY+KODM1uDfXrf1yNg+m2PRyPRf9+nDB0FOHS tZxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :references:in-reply-to:date:cc:to:from:subject:message-id :arc-authentication-results; bh=YFx9n700U1PJGu8pKJ9F7ANZyUD/nfOOV+nxzHwQrqk=; b=LsLHGT+496Mx06xEAnQSzzNTqPPy8t8Tg2PXcHRZ+3uDlPaDAlhVM0PDMhaHWk8L6X mhJQ9rtncb8T4qK2B6yg9pszvSXdicwOIVlqfSko+kj5I2BP/BlIt7qPQm11c4EvXcHO zzYpKJ6+nW6rSGp4AAf8qF3quzGD6Wq8rLyr8dwUWkcOb4+v6EW9uWEtrPF54kLyU+vb 4ZWEVLA26M53fygZcUt4S46ZFHWF9iP9gCTOw3YwxTqNJ3l+XJI0lS6BrmBx3MRyJM5i brIG73QAPDJwaVkPALTWWaeebKXth3eJBvhLiW3pS58WMLuAWZJShchpx6iZZArixD8b baFw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x127-v6si20424686pgb.618.2018.08.14.11.46.23; Tue, 14 Aug 2018 11:46:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728237AbeHNVeG (ORCPT + 99 others); Tue, 14 Aug 2018 17:34:06 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:26487 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727755AbeHNVeG (ORCPT ); Tue, 14 Aug 2018 17:34:06 -0400 X-UUID: f692c6cbf4e6438cb9cfdc241a35dade-20180815 Received: from mtkcas07.mediatek.inc [(172.21.101.84)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1878632844; Wed, 15 Aug 2018 02:45:29 +0800 Received: from mtkcas08.mediatek.inc (172.21.101.126) by mtkexhb02.mediatek.inc (172.21.101.103) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Wed, 15 Aug 2018 02:45:28 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkcas08.mediatek.inc (172.21.101.126) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Wed, 15 Aug 2018 02:45:27 +0800 Received: from [172.21.77.33] (172.21.77.33) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1210.3 via Frontend Transport; Wed, 15 Aug 2018 02:45:20 +0800 Message-ID: <1534272320.31978.28.camel@mtkswgap22> Subject: Re: [PATCH] Bluetooth: mediatek: Fix memory leak From: Sean Wang To: "Gustavo A. R. Silva" CC: Marcel Holtmann , Johan Hedberg , Matthias Brugger , , , , Date: Wed, 15 Aug 2018 02:45:20 +0800 In-Reply-To: <20180814151031.GA25096@embeddedor.com> References: <20180814151031.GA25096@embeddedor.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3-0ubuntu6 Content-Transfer-Encoding: 7bit MIME-Version: 1.0 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Gustavo thanks for the catch up Acked-by: Sean Wang On Tue, 2018-08-14 at 10:10 -0500, Gustavo A. R. Silva wrote: > In case memory resources for *fw* were allocated, release them before > return. > > Addresses-Coverity-ID: 1472611 ("Resource leak") > Fixes: 7237c4c9ec92 ("Bluetooth: mediatek: Add protocol support for MediaTek serial devices") > Signed-off-by: Gustavo A. R. Silva > --- > drivers/bluetooth/btmtkuart.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/drivers/bluetooth/btmtkuart.c b/drivers/bluetooth/btmtkuart.c > index ed2a5c7..4593baf 100644 > --- a/drivers/bluetooth/btmtkuart.c > +++ b/drivers/bluetooth/btmtkuart.c > @@ -144,8 +144,10 @@ static int mtk_setup_fw(struct hci_dev *hdev) > fw_size = fw->size; > > /* The size of patch header is 30 bytes, should be skip */ > - if (fw_size < 30) > - return -EINVAL; > + if (fw_size < 30) { > + err = -EINVAL; > + goto free_fw; > + } > > fw_size -= 30; > fw_ptr += 30; > @@ -172,8 +174,8 @@ static int mtk_setup_fw(struct hci_dev *hdev) > fw_ptr += dlen; > } > > +free_fw: > release_firmware(fw); > - > return err; > } >