Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5597768img; Wed, 27 Mar 2019 11:24:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqym6JzH92PnKnDbPGqK/l/ZMM5v/BIqPU0/VqFkmjOcAbiqqohYXNASAxGsxLfWFo2tchaC X-Received: by 2002:a17:902:31a4:: with SMTP id x33mr2417770plb.24.1553711046146; Wed, 27 Mar 2019 11:24:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553711046; cv=none; d=google.com; s=arc-20160816; b=DQI5QFjUdriUlfUeoamnKqvZspKTuRDKiE+oTomibjyN/8b/utrZMY2WxckyYsBzxL J/pj4JqayXenyxuILfrr+Uj+2sTw4SpUeDqUvK6LWca1l0PGypWjXgnqgQVgvz0ZAN7N pneDs3dDkhBoQzDmrqJWCwZlz6mmQ4dFV+sZgr9yHfx35H85wYPToPqg0MaoDzzI6Hh/ 1AzVi4Em1iMNRgy84p9sNYdiyY/LijE4QdY2OXZ+sFDollytygzOJLTt7NJJkuGarSLq KYcNWtucEtjVpwz2YjidVBU0cjkHsvi8nMHrQnazaHlr/t2ONGX2Yho31j96MsEDahdv wB5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/ByEtW+KGsQE/FyfC76Y3rUHlioXEyzK/AzTy246/iE=; b=Xj1oAUGpRWzRztZtwuLn12htY0aOy45c3W32Co2IqMBS0EgFGbPXlX/25DGC7ktA4K W7Qd+VXbI0nbv2qvyTRmvVFvcjPwv4Mw1dGJpKSmyj8QRTjqyIte0bMML+icsyWea91a md62Zhl/je2XNOjBpaAfeZEOGKr2wuIZ6uFFRIzsIvrBdtWeBWYF2ckprOs5XIVs5lxF yz+ovOUOglcKExxJoQj9eQrrzlDEIlGFF50usxMvM6LKc139LfZhDZ7PaEq3c6mMpYUp YFQbtsIGyQGaZz37WyT5rwKGRapadxHCQvPwlqWUS2AbIZpG6q5h1N89SwEc8Tj8oV7U Gilg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Q8q9u1FQ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k13si5824206pll.200.2019.03.27.11.23.51; Wed, 27 Mar 2019 11:24:06 -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; dkim=pass header.i=@kernel.org header.s=default header.b=Q8q9u1FQ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390452AbfC0SXT (ORCPT + 99 others); Wed, 27 Mar 2019 14:23:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:41666 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391446AbfC0SXQ (ORCPT ); Wed, 27 Mar 2019 14:23:16 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4D48420643; Wed, 27 Mar 2019 18:23:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553710996; bh=DCLEt9aT55hFlCcygNM65d7H2MmkdZ8pjnyfQAVwuD8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q8q9u1FQwDRhXIJEWtdwWUG0elbDBzL8fXE5JuwBvY6PLUmFygCSB/p5q9bE8twsg tK/z5hTcRpP0fDitiTSNpQaFSJM7N6dFyKvBVBJH3OxFsthM6UQRQzc5+NG+VdJTmT fN6V5wIzsoRhA3sPdZjVojn36Zd33KKwi0T93VSY= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Zumeng Chen , Kalle Valo , Sasha Levin , linux-wireless@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.9 83/87] wlcore: Fix memory leak in case wl12xx_fetch_firmware failure Date: Wed, 27 Mar 2019 14:20:36 -0400 Message-Id: <20190327182040.17444-83-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327182040.17444-1-sashal@kernel.org> References: <20190327182040.17444-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zumeng Chen [ Upstream commit ba2ffc96321c8433606ceeb85c9e722b8113e5a7 ] Release fw_status, raw_fw_status, and tx_res_if when wl12xx_fetch_firmware failed instead of meaningless goto out to avoid the following memory leak reports(Only the last one listed): unreferenced object 0xc28a9a00 (size 512): comm "kworker/0:4", pid 31298, jiffies 2783204 (age 203.290s) hex dump (first 32 bytes): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace: [<6624adab>] kmemleak_alloc+0x40/0x74 [<500ddb31>] kmem_cache_alloc_trace+0x1ac/0x270 [] wl12xx_chip_wakeup+0xc4/0x1fc [wlcore] [<76c5db53>] wl1271_op_add_interface+0x4a4/0x8f4 [wlcore] [] drv_add_interface+0xa4/0x1a0 [mac80211] [<65bac325>] ieee80211_reconfig+0x9c0/0x1644 [mac80211] [<2817c80e>] ieee80211_restart_work+0x90/0xc8 [mac80211] [<7e1d425a>] process_one_work+0x284/0x42c [<55f9432e>] worker_thread+0x2fc/0x48c [] kthread+0x148/0x160 [<63144b13>] ret_from_fork+0x14/0x2c [< (null)>] (null) [<1f6e7715>] 0xffffffff Signed-off-by: Zumeng Chen Signed-off-by: Kalle Valo Signed-off-by: Sasha Levin --- drivers/net/wireless/ti/wlcore/main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ti/wlcore/main.c b/drivers/net/wireless/ti/wlcore/main.c index 5438975c7ff2..17d32ce5d16b 100644 --- a/drivers/net/wireless/ti/wlcore/main.c +++ b/drivers/net/wireless/ti/wlcore/main.c @@ -1058,8 +1058,11 @@ static int wl12xx_chip_wakeup(struct wl1271 *wl, bool plt) goto out; ret = wl12xx_fetch_firmware(wl, plt); - if (ret < 0) - goto out; + if (ret < 0) { + kfree(wl->fw_status); + kfree(wl->raw_fw_status); + kfree(wl->tx_res_if); + } out: return ret; -- 2.19.1