From patchwork Thu Dec 8 23:01:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Wang X-Patchwork-Id: 13069001 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 73BD7C4332F for ; Thu, 8 Dec 2022 23:02:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=NTBVcrw/RxDyuO/cK09YB58QDkSEkLZcwgUnaxT/PQ0=; b=uGan5qwG9YCAVS6RqYWVlNY+Ok un2CuqvPI2Yg34EY7oz9IZJacPNWm1SytFovtIfAWOKm1c0Veg9pRjpjfG74bSgWVdLdId01UO8NC mkK3W1zLxX3x+rLCDgk3owBtDfiKflpsnpQiZ3p0bcs5qVPpFwJbdzrhJsaq25jwhUoAo94VZ3hA9 xAn28yD0klO/ryXgzbmUupquNtpQvUK2CDm8g2pCGeFw+Ltvl0lz1lYt72AlP6W1MU0vlYJzE3lsn I1B5EpkPQsgxdeVU7NUvBPoKhgt3LRbf3OqltyUeIBSnvkuRYGpG0egE/l5U9PqqBDegOFPeNnNXr p7GZEe/g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p3PuA-00Ef6B-46; Thu, 08 Dec 2022 23:02:14 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p3Pu6-00Eexz-NV for linux-mediatek@lists.infradead.org; Thu, 08 Dec 2022 23:02:12 +0000 X-UUID: 2223e41902cc4872b234699f291dc623-20221208 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=NTBVcrw/RxDyuO/cK09YB58QDkSEkLZcwgUnaxT/PQ0=; b=RHpXLS9hORWVGOlMBz3qrDC5Lpi6rvTCNdv3cD2/2PgNPQruLFSL/EKnqL5YZZFYU8WcN1DXZkl2yNCv0TS/0kurtAxe16pWWFh95xYDVSPx/ngUz870Cj/NDDkC2fW/UVvYjfS9IxG8Y2QWbhUwHC07ib8f63WZgUdeG+p/isk=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.14,REQID:3bb6b38b-a63f-4322-9943-fda510717db9,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:-5 X-CID-META: VersionHash:dcaaed0,CLOUDID:fd5ef516-b863-49f8-8228-cbdfeedd1fa4,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:11|1,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0 X-UUID: 2223e41902cc4872b234699f291dc623-20221208 Received: from mtkmbs11n2.mediatek.inc [(172.21.101.187)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1426670802; Thu, 08 Dec 2022 16:02:00 -0700 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Fri, 9 Dec 2022 07:01:58 +0800 Received: from mtkswgap22.mediatek.inc (172.21.77.33) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Fri, 9 Dec 2022 07:01:58 +0800 From: To: , CC: , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH] wifi: mt76: mt7921: resource leaks at mt7921_check_offload_capability() Date: Fri, 9 Dec 2022 07:01:57 +0800 Message-ID: <1670540517-21517-1-git-send-email-sean.wang@mediatek.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221208_150210_839593_2344268F X-CRM114-Status: UNSURE ( 8.79 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org From: Sean Wang Fixed coverity issue with resource leaks at variable "fw" going out of scope leaks the storage it points to mt7921_check_offload_capability(). Reported-by: coverity-bot Addresses-Coverity-ID: 1527806 ("Resource leaks") Fixes: 034ae28b56f1 ("wifi: mt76: mt7921: introduce remain_on_channel support") Signed-off-by: Sean Wang Reviewed-by: AngeloGioacchino Del Regno --- drivers/net/wireless/mediatek/mt76/mt7921/init.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/init.c b/drivers/net/wireless/mediatek/mt76/mt7921/init.c index 542dfd425129..d4b681d7e1d2 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/init.c @@ -175,7 +175,7 @@ u8 mt7921_check_offload_capability(struct device *dev, const char *fw_wm) if (!fw || !fw->data || fw->size < sizeof(*hdr)) { dev_err(dev, "Invalid firmware\n"); - return -EINVAL; + goto out; } data = fw->data; @@ -206,6 +206,7 @@ u8 mt7921_check_offload_capability(struct device *dev, const char *fw_wm) data += le16_to_cpu(rel_info->len) + rel_info->pad_len; } +out: release_firmware(fw); return features ? features->data : 0;