From patchwork Fri Oct 7 06:49:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 9365699 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 7DED560487 for ; Fri, 7 Oct 2016 06:49:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 628F429349 for ; Fri, 7 Oct 2016 06:49:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 564FB2934A; Fri, 7 Oct 2016 06:49:44 +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 20AA429347 for ; Fri, 7 Oct 2016 06:49:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754620AbcJGGt2 (ORCPT ); Fri, 7 Oct 2016 02:49:28 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:34960 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752398AbcJGGt1 (ORCPT ); Fri, 7 Oct 2016 02:49:27 -0400 Received: by mail-pf0-f195.google.com with SMTP id t25so2367550pfg.2 for ; Thu, 06 Oct 2016 23:49:27 -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=iWGe/Y5/lY6VLxxUOG6GaYBD4qptoxd5Ji6UeumTErc=; b=qvJoc0CNSCoApY9Vtt650SdK/aqjXjkxt7SsC97w68DBPgUMEyG0hV7pQc5ENcZRvS 9VN7fJsr2GUKWkYW8Zt5IlqkxVdp4EHMOH+heLbhuKGQ62GQAgirJZ6uNpR2kKX4d102 7iF4WQd+Lc9dIg3IUT/gfCjGn4ololmvnJiPxplRjhMOhlsWD8w5o0qtPWTAA5sVn9ME djrezLCYnJv+gQ++/VyeHbFZ2L/AFf9czcZFFX89KBgBjlTjCFXaF3F3IwqkUD1ZCkqf aGki0iEPQ2NzDJIMHhYoCbYGDA3IMvNB3TPilKJcktscXIzZVWYDFQfUNLLjH7XMssjG HSsw== 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=iWGe/Y5/lY6VLxxUOG6GaYBD4qptoxd5Ji6UeumTErc=; b=WnOOfF1K4f8ZdmvA9gIytLCGme9aQWv3HniX7B1a8I5CdlcdXyDSaoZ45oCGf69u0Z gd4EMlflJMArixqC9Jhau109XYD1BTzej+tgDBhoepKp+SlOEtWSXuppmo706HXgp/pR ZeTNQ3WOaxh3HnPqefYY1OGo7heAbCNofDgsfF8Ez1srByP2oe+NLg/pqkndBBNmIo+a QvvX24IZDlhnjbMhKIM83YpEYgPzqAbNSJ9TEZp6VUmOdjCwTnKYeN3+Z/ZSeavm4Xeo 7rpgxkXxcSuRyySdFomk0LgGok8i/xf39/fvulvNcHJPYTRQfyqU2BHh4zNmVXDPL8ia ltJg== X-Gm-Message-State: AA6/9Rl+nMVMT8KNdTKnI/X6NGHRgYbDku08FxlZxUYF0Yz9fniyrwk6QolTp5pdPXau5A== X-Received: by 10.98.92.197 with SMTP id q188mr33191735pfb.31.1475822966653; Thu, 06 Oct 2016 23:49:26 -0700 (PDT) Received: from symbol-HP-ZBook-15 ([140.101.159.249]) by smtp.gmail.com with ESMTPSA id ah5sm27711952pad.30.2016.10.06.23.49.25 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 06 Oct 2016 23:49:25 -0700 (PDT) Date: Fri, 7 Oct 2016 12:19:23 +0530 From: Souptick Joarder To: linux-wireless , Julian Calaby , Kalle Valo Cc: Rameshwar Sahu Subject: [PATCH] wl18xx: Handle kfree() in better way when kzalloc fails Message-ID: <20161007064923.GA3404@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 handle kfree and return error in a better way if kzalloc fails in wl18xx_scan_send() and wl18xx_scan_sched_scan_config(). Signed-off-by: Souptick joarder --- 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; }