Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5587120img; Wed, 27 Mar 2019 11:12:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqwQuhk8MSOktN427KkX2wFIaXTJ0HKpipVUY9HzGkFeasxHspsDBydhNFmFQQ7Oy5uXRbFm X-Received: by 2002:a17:902:2848:: with SMTP id e66mr39149638plb.181.1553710329758; Wed, 27 Mar 2019 11:12:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553710329; cv=none; d=google.com; s=arc-20160816; b=PWkIjm5XJFfEcnpcLwuUXZObvgcYUEgifAmwbMaziGgD/q7To1x+2P9JrTsaTCXwJj Fzh3+kLEcAX6fT3DwZtFZEz4S5s9UbI0hf3X1N/N807geyC6QwYVXyt06D9iyuDJav7m y3uc8DfvMw+LukTxP+TrOKcoTAn0sjrn8GSHZtqvGDXHemzULlzw7buMVBp4i2Ne70Io GntI3cfkGxIybmbgZp0q1QllE3Tc9g9Xha+rzxUqRng5bzMtQ0rbdCRGXse7h7I1peNi gs/nbzzXn7zh1xtnLViNXT3KyEvnHHtZo9yqbIAzH78kSA1nBZnrC1LAaE4vXY/7K2lP UioA== 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=EzQEJPdDNz/fbChfcSnwwS7QwgWm/SGUd4BXEODQ2Ak=; b=LeswWLQLEQrV/xbFyWp0LtT8p4J1T0jcU0kgvZ9RqWPjbRNsxBgvOXxDB85lIflojV lDnFO3K03LPcm46usEdfIUJNKdanWKKT/LSKWlfRLOBVEIaTGeQFsurLbzLiWKbMDYsP mFbbv1c+6KEy8qlA58NIClWGVSmRXdyUs+D8wrM1a3U+ASAfyVxCuys5GxQsxE3cKrnM RupzTs3swB2Y43hYRhbzKe6cMwMgPpSz/87kOqKw4dpnAxIMxtUgQ6L9ei19RGFJepYM qvG06UiOyxkpWz9p2bxuIwS4JHWFpQ/bQ7F1mw0TMo6SCkDUD6gBNwdgvgnsAikL6eV8 ed0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jQ2ReW0C; 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 60si21216752plf.122.2019.03.27.11.11.54; Wed, 27 Mar 2019 11:12:09 -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=jQ2ReW0C; 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 S2388291AbfC0SKB (ORCPT + 99 others); Wed, 27 Mar 2019 14:10:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:51902 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388678AbfC0SJ7 (ORCPT ); Wed, 27 Mar 2019 14:09:59 -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 BF2A9217F9; Wed, 27 Mar 2019 18:09:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553710198; bh=msjFF8eo6gGgMTQ4XxMKfeipSQsjw7auNNcjzzP9jFg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jQ2ReW0C7nZv08CYHkhZHLFzBFJxeBnnz048hMctzAx4R+1iqeyTSL4N5mrnZB9xb kmuj9lPAxsVEF+mj6zWCWSQXgteMl4eWAsLdMGl+NnWvz8k4jf8zUNiytHOwQfyM9K cQMkvmjp9nSNyjLWxBaYVDzkGYWNcU2QzHA9N11I= 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 5.0 246/262] wlcore: Fix memory leak in case wl12xx_fetch_firmware failure Date: Wed, 27 Mar 2019 14:01:41 -0400 Message-Id: <20190327180158.10245-246-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327180158.10245-1-sashal@kernel.org> References: <20190327180158.10245-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 26b187336875..2e12de813a5b 100644 --- a/drivers/net/wireless/ti/wlcore/main.c +++ b/drivers/net/wireless/ti/wlcore/main.c @@ -1085,8 +1085,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