Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1000489yba; Thu, 4 Apr 2019 02:07:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqyy3CNjlhjYY7mlHe5EuvYFbO34jsPR/2I3u1onxDLpwn0ged0MiKr3FES017b+hZywdOGj X-Received: by 2002:a63:cc0a:: with SMTP id x10mr4511084pgf.179.1554368852645; Thu, 04 Apr 2019 02:07:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554368852; cv=none; d=google.com; s=arc-20160816; b=fAzx7UDSK3zmfmqy9qkxqOybXY3d+KE5K/yN3ArCe7iXVu9ZOQ4+lz4ZNAdfvkcuF6 rJsZlOV6fgHQABhepc1dFW370ZLBS1PDKzAIC6uPhkF2I0VgNZCUJ2EovLcwW2St6JsR OqnyhG931EMfqiOaF5+0xTCzsOs/LaCWkyeXBg0pEq0gWdJ6kB2IGrJcz6NIqYuH0Wo8 gilfH++VnBjaxjQWRtEwDuCVwtBKZ9qMUhF+1oNdkk0iE48i20k0AWx9JOqN7QOvPFNG p51AJNMcKj/qO3vHLK4kG8AJaEsZCR2CECIWlzM5tmVB1H2Me72bOzZ4RsMo9snxn3NH TTnA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=v0Xlc7VkZZv71WYPuAuYkH+Jbi6v+Hd1MlGgH/9JhbM=; b=klV2UU5QTwZynYGeuTDjQpZqsluJuy1xRW0ua6VJszMU5g19r+VjEib5w37djUFib1 m6pLXKrF0hL6Ld8XQlOR7rKi+nsiYgVsMoC8mJd+T8VAoYTzrgfHgHweoJrVph2px+hn HGttuJhv4xXVZNn+EM2FkbgLvMH+yEx/468ThcEZTce9sUkN9iljUEvcUlLfb1SrdQPl sDhgoac5VtzBjraraAEtLXnYvokmYnWKr+hXJYy5l+9yE0lLrrHRpRP+Lh6QMzg8f/2Q 9Fos3BpG0f/qb7KID+HR3C1LbOxR5UQmEEnZ9F1hXJQ6eu93gOn1IEOxxIQspL7DxTyB UVqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QMs3G4uy; 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 35si16080333pgz.383.2019.04.04.02.07.17; Thu, 04 Apr 2019 02:07:32 -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=QMs3G4uy; 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 S1732371AbfDDJGo (ORCPT + 99 others); Thu, 4 Apr 2019 05:06:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:45304 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731576AbfDDJGn (ORCPT ); Thu, 4 Apr 2019 05:06:43 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id ACBB9214AF; Thu, 4 Apr 2019 09:06:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554368803; bh=uNcEBcBJFPNua8sY2kxw/P2w7tlod3gFYnt+hnTxyrU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QMs3G4uyezNbWKZh6a0mIBTaBmJGf/w0uofNyDa6x6MMUo9Sh8g4mPzGmlJCfcQ8Q to+a7M6kaobsGPHfCZ2P4L1FPn0pJ/5rLxEDNSZu0SayryHY6H1tnF4zVOtdASAR1y y6jXElkOXbazCdJ4bac620aPb1tGAJW2kxFG/zag= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zumeng Chen , Kalle Valo , Sasha Levin Subject: [PATCH 4.19 176/187] wlcore: Fix memory leak in case wl12xx_fetch_firmware failure Date: Thu, 4 Apr 2019 10:48:33 +0200 Message-Id: <20190404084611.402025405@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084603.119654039@linuxfoundation.org> References: <20190404084603.119654039@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ [ 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 19e3c5a0b715..2ca5658bbc2a 100644 --- a/drivers/net/wireless/ti/wlcore/main.c +++ b/drivers/net/wireless/ti/wlcore/main.c @@ -1084,8 +1084,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