From patchwork Wed Oct 5 11:50:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 9362751 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3B1986077E for ; Wed, 5 Oct 2016 11:50:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 215DF2880D for ; Wed, 5 Oct 2016 11:50:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 15D5A28814; Wed, 5 Oct 2016 11:50:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AAA4B2880D for ; Wed, 5 Oct 2016 11:50:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752232AbcJELuT (ORCPT ); Wed, 5 Oct 2016 07:50:19 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:35349 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750855AbcJELuS (ORCPT ); Wed, 5 Oct 2016 07:50:18 -0400 Received: by mail-pf0-f194.google.com with SMTP id t25so6217863pfg.2 for ; Wed, 05 Oct 2016 04:50:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=JPZnBxvIpefSlzQvmqWfd50aOv5hHK234LFSoKpYCbY=; b=nO00eVi465FaVvHJWmSg4Zbr/sNv/SD/h21M3aruNPDYw/zL0M9uz5oXVKG6Fe+QPe EEXhrBpAqd+1U1WCfyftbrFQririoYcCHx7bduVB6pxmy5GjemhkMKs9YOTUnbUyb4UT Ab7+j9gaXQzGxYwbOMNw1a8+801UQZcJKBDGkat8k9NWu18uxN9baOqsEzQPRwjkhzrJ dB0eH64efDj2TDblrff7nQtpLoQzOcUvJ1cqtxQIQTQuMSkn7+LuWLbr27mIfmCGvik0 K2HfRN9OGMmoVz6Zn0VJGI+m9cNXJz4k3MMaTFwrGPJYr1v83l5Tx4wn4TELdHWigbZm 2i0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=JPZnBxvIpefSlzQvmqWfd50aOv5hHK234LFSoKpYCbY=; b=Vc5ianrwxYhzrsebW/bz+TRfvLqhDRIVfO939rJ7WX+U5FFFI5B6nbE1WuOshccjF6 8dxqNbPUPpPNEj0i95ruq+MwTjbFD3twkWaujeejT4PjvjjNZCRz+0DvVYc5+ggW6K1P pVWCr2B2eb1eNpJSHRBSRXl8/UwuktMNSia99Aov1ZV2nI9kgomamOft756AZ713pbzj Vs+phTkZF8l4CuFMvC1HwFa/KJCuQObUts+1nhx7aQnRRdjxUj4lPxmisXABd4AM7Qy1 lStZK2mVYTWyN+wIYjzoEXNAU9oOEx+qL1ZZjArrG90jFfZf3FLAnBNbqU8qSEun7COC w77Q== X-Gm-Message-State: AA6/9Rnm/KZZFUgLVTwG/bMjqdLi6sG3PSv85fw6rVKL6FuvTxaLAKC7vIfJD42O6s4JhQ== X-Received: by 10.98.200.153 with SMTP id i25mr6098579pfk.156.1475668217394; Wed, 05 Oct 2016 04:50:17 -0700 (PDT) Received: from symbol-HP-ZBook-15 ([140.101.159.249]) by smtp.gmail.com with ESMTPSA id c27sm3856297pfe.6.2016.10.05.04.50.16 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 05 Oct 2016 04:50:16 -0700 (PDT) Date: Wed, 5 Oct 2016 17:20:13 +0530 From: Souptick Joarder To: linux-wireless@vger.kernel.org Cc: sahu.rameshwar73@gmail.com Subject: [PATCH] [wl18xx] Fix memory leakage if kzalloc fails Message-ID: <20161005115013.GA22099@symbol-HP-ZBook-15> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch is added to properly handle memory leak if kzalloc fails in wl18xx_scan_send() and wl18xx_scan_sched_scan_config() Signed-off-by: Souptick Joarder Signed-off-by: Rameshwar Sahu --- drivers/net/wireless/ti/wl18xx/scan.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/ti/wl18xx/scan.c b/drivers/net/wireless/ti/wl18xx/scan.c index 4e522154..aed22e1 100644 --- a/drivers/net/wireless/ti/wl18xx/scan.c +++ b/drivers/net/wireless/ti/wl18xx/scan.c @@ -41,14 +41,13 @@ static void wl18xx_adjust_channels(struct wl18xx_cmd_scan_params *cmd, static int wl18xx_scan_send(struct wl1271 *wl, struct wl12xx_vif *wlvif, struct cfg80211_scan_request *req) { - struct wl18xx_cmd_scan_params *cmd; + struct wl18xx_cmd_scan_params *cmd = NULL; struct wlcore_scan_channels *cmd_channels = NULL; int ret; cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); if (!cmd) { - ret = -ENOMEM; - goto out; + return -ENOMEM; } /* scan on the dev role if the regular one is not started */ @@ -59,7 +58,7 @@ static int wl18xx_scan_send(struct wl1271 *wl, struct wl12xx_vif *wlvif, if (WARN_ON(cmd->role_id == WL12XX_INVALID_ROLE_ID)) { ret = -EINVAL; - goto out; + goto err_cmd_free; } cmd->scan_type = SCAN_TYPE_SEARCH; @@ -84,7 +83,7 @@ static int wl18xx_scan_send(struct wl1271 *wl, struct wl12xx_vif *wlvif, cmd_channels = kzalloc(sizeof(*cmd_channels), GFP_KERNEL); if (!cmd_channels) { ret = -ENOMEM; - goto out; + goto err_cmd_free; } wlcore_set_scan_chan_params(wl, cmd_channels, req->channels, @@ -153,6 +152,7 @@ static int wl18xx_scan_send(struct wl1271 *wl, struct wl12xx_vif *wlvif, out: kfree(cmd_channels); +err_cmd_free: kfree(cmd); return ret; } @@ -171,7 +171,7 @@ int wl18xx_scan_sched_scan_config(struct wl1271 *wl, struct cfg80211_sched_scan_request *req, struct ieee80211_scan_ies *ies) { - struct wl18xx_cmd_scan_params *cmd; + struct wl18xx_cmd_scan_params *cmd = NULL; struct wlcore_scan_channels *cmd_channels = NULL; struct conf_sched_scan_settings *c = &wl->conf.sched_scan; int ret; @@ -185,15 +185,14 @@ int wl18xx_scan_sched_scan_config(struct wl1271 *wl, cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); if (!cmd) { - ret = -ENOMEM; - goto out; + return -ENOMEM; } cmd->role_id = wlvif->role_id; if (WARN_ON(cmd->role_id == WL12XX_INVALID_ROLE_ID)) { ret = -EINVAL; - goto out; + goto err_cmd_free; } cmd->scan_type = SCAN_TYPE_PERIODIC; @@ -218,7 +217,7 @@ int wl18xx_scan_sched_scan_config(struct wl1271 *wl, cmd_channels = kzalloc(sizeof(*cmd_channels), GFP_KERNEL); if (!cmd_channels) { ret = -ENOMEM; - goto out; + goto err_cmd_free; } /* configure channels */ @@ -296,6 +295,7 @@ int wl18xx_scan_sched_scan_config(struct wl1271 *wl, out: kfree(cmd_channels); +err_cmd_free: kfree(cmd); return ret; }