From patchwork Wed Oct 5 13:09:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 9362897 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 D32036077E for ; Wed, 5 Oct 2016 13:09:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C5EC028532 for ; Wed, 5 Oct 2016 13:09:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BA508285A2; Wed, 5 Oct 2016 13:09:23 +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 5D7A028532 for ; Wed, 5 Oct 2016 13:09:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752425AbcJENJV (ORCPT ); Wed, 5 Oct 2016 09:09:21 -0400 Received: from mail-pa0-f66.google.com ([209.85.220.66]:34220 "EHLO mail-pa0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752220AbcJENJV (ORCPT ); Wed, 5 Oct 2016 09:09:21 -0400 Received: by mail-pa0-f66.google.com with SMTP id r9so10624847paz.1 for ; Wed, 05 Oct 2016 06:09:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:mime-version:content-disposition :user-agent; bh=JPZnBxvIpefSlzQvmqWfd50aOv5hHK234LFSoKpYCbY=; b=pjjbvqCmiYyZz++hemxi74Va12jTh7w/YCIxE+gIYmcnmmY+pHBSfqzVRXuWtaTuCR iknhDsmZi6zKPKH990wo7yYckmaEEgfWnbxj0OT0onGBHR3F/Ii3IEUtOnhvZ3WA29ov qPEbwkKirsqODmMDzx6C51ZeGP51QpKS0l8gDhxpismQRA8i3jKpXnQK3oH6Nwx11g3d k5W70CaXNu+0E3sE52UT33PnuSaDJBYvq59wDshnX+64dsP7PyS0J5CvJ1bB729jEjzs mW4ZH/7Vth4rdFPhBtHcXSHBFIbfG8tTCqCOfc5EeELb3v0FKqKhQ6OxXg0HsJiVlFGW SsCA== 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:subject:message-id:mime-version :content-disposition:user-agent; bh=JPZnBxvIpefSlzQvmqWfd50aOv5hHK234LFSoKpYCbY=; b=N8aJ53+DNLLgq5xwyFJcWpwX0PE5zx45ubdKsKbVEUAaVlSvenZTNAPSFh3naM7OUB 3K5FAX6kbUhjFBZaKwuWHCSs2dJ4xicFPGIxLph/StSabda8cMSzWtoQqG0hQDlQf9MP 48prbYWMM4HMA7KDRPVqpHql+nMIPlpgUkVbcfKwy9af2VMIYezQPYob6NpBcmQUTsga diwLkaSWffbkZzqb+gzKXxuctAw+Hy9NT0faAqf/yzNkmxHH4qg6GH4Y+K3eo/B7Gwr0 k5lPWF3asRNDl0Rgbk4QC7P4JdLFl09R5tMVpMdPwkuwVIxqzqGPghw5Fp2C34TYWPDX 8A4Q== X-Gm-Message-State: AA6/9RmT0AixXigKA8VTMSinvD2WePKobQz2jcUX7E+2Nur5zd3sucgCYMO2B4fPAZy2Ew== X-Received: by 10.67.16.76 with SMTP id fu12mr13270607pad.171.1475672959778; Wed, 05 Oct 2016 06:09:19 -0700 (PDT) Received: from symbol-HP-ZBook-15 ([140.101.159.249]) by smtp.gmail.com with ESMTPSA id d19sm11434285pfd.59.2016.10.05.06.09.18 for (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 05 Oct 2016 06:09:19 -0700 (PDT) Date: Wed, 5 Oct 2016 18:39:16 +0530 From: Souptick Joarder To: linux-wireless@vger.kernel.org Subject: [PATCH] [wl18xx] Fix memory leakage if kzalloc fails Message-ID: <20161005130916.GA22804@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; }