From patchwork Fri May 11 08:13:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Singh X-Patchwork-Id: 10393577 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 3D2B260236 for ; Fri, 11 May 2018 08:13:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B80828D91 for ; Fri, 11 May 2018 08:13:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1E0DD28E22; Fri, 11 May 2018 08:13:57 +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.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, 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 7215A28D91 for ; Fri, 11 May 2018 08:13:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752697AbeEKINz (ORCPT ); Fri, 11 May 2018 04:13:55 -0400 Received: from esa3.microchip.iphmx.com ([68.232.153.233]:42486 "EHLO esa3.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752357AbeEKINy (ORCPT ); Fri, 11 May 2018 04:13:54 -0400 X-IronPort-AV: E=Sophos;i="5.49,387,1520924400"; d="scan'208";a="14149188" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa3.microchip.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 11 May 2018 01:13:54 -0700 Received: from ajaysk-VirtualBox.microchip.com (10.10.76.4) by chn-sv-exch04.mchp-main.com (10.10.76.105) with Microsoft SMTP Server id 14.3.352.0; Fri, 11 May 2018 01:13:52 -0700 From: Ajay Singh To: CC: , , , , , , , Ajay Singh Subject: [PATCH v2 01/30] staging: wilc1000: added complete() call for error scenario in handle_key() Date: Fri, 11 May 2018 13:43:02 +0530 Message-ID: <1526026411-11058-2-git-send-email-ajay.kathat@microchip.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1526026411-11058-1-git-send-email-ajay.kathat@microchip.com> References: <1526026411-11058-1-git-send-email-ajay.kathat@microchip.com> MIME-Version: 1.0 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 During memory allocation failure in handle_key() the complete() was not called for comp_test_key_block event. So now added the code to call complete() for event during error scenario. Signed-off-by: Ajay Singh --- drivers/staging/wilc1000/host_interface.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index b5f3829..652f51c 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -1513,8 +1513,10 @@ static int handle_key(struct wilc_vif *vif, struct key_attr *hif_key) key_buf = kmalloc(hif_key->attr.wep.key_len + 2, GFP_KERNEL); - if (!key_buf) - return -ENOMEM; + if (!key_buf) { + result = -ENOMEM; + goto out_wep; + } key_buf[0] = hif_key->attr.wep.index; key_buf[1] = hif_key->attr.wep.key_len; @@ -1535,8 +1537,10 @@ static int handle_key(struct wilc_vif *vif, struct key_attr *hif_key) kfree(key_buf); } else if (hif_key->action & ADDKEY) { key_buf = kmalloc(hif_key->attr.wep.key_len + 2, GFP_KERNEL); - if (!key_buf) - return -ENOMEM; + if (!key_buf) { + result = -ENOMEM; + goto out_wep; + } key_buf[0] = hif_key->attr.wep.index; memcpy(key_buf + 1, &hif_key->attr.wep.key_len, 1); memcpy(key_buf + 2, hif_key->attr.wep.key, @@ -1573,6 +1577,7 @@ static int handle_key(struct wilc_vif *vif, struct key_attr *hif_key) &wid, 1, wilc_get_vif_idx(vif)); } +out_wep: complete(&hif_drv->comp_test_key_block); break; @@ -1607,7 +1612,6 @@ static int handle_key(struct wilc_vif *vif, struct key_attr *hif_key) wilc_get_vif_idx(vif)); kfree(key_buf); - complete(&hif_drv->comp_test_key_block); } else if (hif_key->action & ADDKEY) { key_buf = kzalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL); if (!key_buf) { @@ -1636,9 +1640,9 @@ static int handle_key(struct wilc_vif *vif, struct key_attr *hif_key) wilc_get_vif_idx(vif)); kfree(key_buf); - complete(&hif_drv->comp_test_key_block); } out_wpa_rx_gtk: + complete(&hif_drv->comp_test_key_block); kfree(hif_key->attr.wpa.key); kfree(hif_key->attr.wpa.seq); if (ret) @@ -1674,7 +1678,6 @@ static int handle_key(struct wilc_vif *vif, struct key_attr *hif_key) wid_list, 2, wilc_get_vif_idx(vif)); kfree(key_buf); - complete(&hif_drv->comp_test_key_block); } else if (hif_key->action & ADDKEY) { key_buf = kmalloc(PTK_KEY_MSG_LEN, GFP_KERNEL); if (!key_buf) { @@ -1696,10 +1699,10 @@ static int handle_key(struct wilc_vif *vif, struct key_attr *hif_key) &wid, 1, wilc_get_vif_idx(vif)); kfree(key_buf); - complete(&hif_drv->comp_test_key_block); } out_wpa_ptk: + complete(&hif_drv->comp_test_key_block); kfree(hif_key->attr.wpa.key); if (ret) return ret;