Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp126321ybi; Tue, 18 Jun 2019 18:59:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqyL6C/P4G8QnLZ8LctB81ejOlZ2JIJk+EgdS0ii9uYkyT/9mwHbv1UZMBFteXqGMgvAIb+e X-Received: by 2002:a63:1b65:: with SMTP id b37mr5449854pgm.408.1560909585345; Tue, 18 Jun 2019 18:59:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560909585; cv=none; d=google.com; s=arc-20160816; b=uevUlPp06bDHfFj/rA00FOohWZkmUsRLqCMFXMWiljRkDhtp4v8kaeqOzjP3ESTVxY OEPa7WwaStRB6utbUWSvMHNmXqbul1SrvrBMIvcvqTSisbZqBwLdxrmRrKWwN8PbYy65 6z5xpMAM6EGhb9fIhi7ATz0KkRumZmYmDCUNZwbV2APvBRPgEaMoDBSlK5tuck49QmvF hmC+iFIvOvOGAjZZxo+Bj1idLCooL8Vm8X6tzxHgd8P54k256ipTZbVDVgxlbQF3q/RU WR05fEhtQagQJ1LhfechzQyXXnjTRR2pp8fO1muj8/0TvpCCU+2vtm/ValWQJ5Vb2d/+ 7r0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:to:from:date:dkim-signature; bh=DtzpsEMmA6y/VxThJKdgqPMw4atSdDvUpiSanqf0lPA=; b=Xh6Rnm/+tOX5JDK0kQgo6padt5VuJG6crDsF8ACqet6sQiye+MbO7br4E70o/JAl3o vMk/ZZSNxgfmrha+OSMfRmUZbcqjtyyCuOedDEJfIjfmWaJrzvq/TMDkeAHjq0k7AzFi uAux423E3DEZkIhr6j0r3cbQDfhR1IijuIJFchv4ht8AZxzjRwXF7gk0xnS83C2HDN6k jFj5XU6g659BVPvOzSdKcRp8OzpJw4cMQsIuSuATAoiVbF7BaXniUQwGbe+V3e6nufYS e8Wc3Lx29OKkjufUkwvbZXWgShtEPHEvG9VcwKv72EJ/OZims5C4mAdfw0iQ1FVtDlK6 kEuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=BaZDV+wO; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m6si4017465pjl.60.2019.06.18.18.59.29; Tue, 18 Jun 2019 18:59:45 -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=@gmail.com header.s=20161025 header.b=BaZDV+wO; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729740AbfFSB5u (ORCPT + 99 others); Tue, 18 Jun 2019 21:57:50 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:36916 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726037AbfFSB5t (ORCPT ); Tue, 18 Jun 2019 21:57:49 -0400 Received: by mail-pl1-f194.google.com with SMTP id bh12so6486126plb.4 for ; Tue, 18 Jun 2019 18:57:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mime-version:content-disposition :user-agent; bh=DtzpsEMmA6y/VxThJKdgqPMw4atSdDvUpiSanqf0lPA=; b=BaZDV+wO6ImusZDj4cQOtLE/OFaK6teBN6YPViixSjyaqIfOfVDmWt4qSgmzzhO+4l rNjno/gyW56AzTXhsLEU2m80JQu5u3gt0iyt5S4gcCBEeJOPd73ZmQU9quFH24SI34JH 7WoKEt/tJYcpT7wPqtAlho2FcVvDYTAWp35Ceug20SqujuXlyrPHvtcfWKKrvQmJ0tFM BzRDlhCHPWigZsI6exq4gGrgvxlaK5Oww/q5T9nIReszwzKWtRLtkhR3jyPmLz7FDJHN sQQn9lqef32jdMlxDCVKz/4FoBQfawT+KNALwX4w7UqNsCT2KwdIQli5YuPEMO424jF2 3AVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=DtzpsEMmA6y/VxThJKdgqPMw4atSdDvUpiSanqf0lPA=; b=gN3bzvt6BU8A3csStQCTl/tWGXd+AWsfobGLIa32j4VmKKuKMzOJ9e0ihtdnfg6Eix XqCwuISXl7ssntllhWR5hpbzv9s2WQPwiZDweJXV0Oal7vsf51KexofbDHEjfEsGf6HZ xLpA2pUKH/eicevC7KS/fq6fimfBbM4P0oBHz+1Y2dllHKvOuRfwmggHZJm8gKH5Yxs4 ZCsZYfXZ3oAoERmQgKxB7vnT9dsQdJjNWGGkIfVN6/PQBkBL4oEV+1uKJZz8RfpoHgww oqjHLK9V3/xwJMfR5kjpseBRslgMV2wseLcqzjHp8fSXxYAHoVComqi+S4fqugf8Prd6 m4sg== X-Gm-Message-State: APjAAAUczosWCM1r0m6Od/IwJNjpmWsnZln+yMB5jtAVGi6aZh6INQXr lxHaghJsTl85629NojUBwvc= X-Received: by 2002:a17:902:a5c5:: with SMTP id t5mr118819238plq.288.1560909469154; Tue, 18 Jun 2019 18:57:49 -0700 (PDT) Received: from hari-Inspiron-1545 ([183.83.92.187]) by smtp.gmail.com with ESMTPSA id x26sm14327540pfq.69.2019.06.18.18.57.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Jun 2019 18:57:48 -0700 (PDT) Date: Wed, 19 Jun 2019 07:27:43 +0530 From: Hariprasad Kelam To: Greg Kroah-Hartman , Michael Straube , Mamta Shukla , Hariprasad Kelam , Nishka Dasgupta , Emanuel Bennici , Puranjay Mohan , Shobhit Kukreti , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [Patch v3] staging: rtl8723bs: os_dep: ioctl_linux: make use of kzalloc Message-ID: <20190619015742.GA19278@hari-Inspiron-1545> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch is a cleanup which replaces rtw_malloc(wep_total_len) with kzalloc() and removes the memset(). The rtw_malloc() does GFP_ATOMIC allocations when in_atomic() is true. But as the comments for in_atomic() describe, the in_atomic() check should not be used in driver code. The in_atomic() check is not accurate when preempt is disabled. In this code we are not in IRQ context and we are not holding any spin_locks so GFP_KERNEL is safe. Signed-off-by: Hariprasad Kelam ---- changes in v2: Replace rtw_zmalloc with kzalloc changes in v3: Add proper changelog --- --- drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index ea50ec424..e050f20 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -477,14 +477,12 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, if (wep_key_len > 0) { wep_key_len = wep_key_len <= 5 ? 5 : 13; wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial); - pwep = rtw_malloc(wep_total_len); + pwep = kzalloc(wep_total_len, GFP_KERNEL); if (pwep == NULL) { RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, (" wpa_set_encryption: pwep allocate fail !!!\n")); goto exit; } - memset(pwep, 0, wep_total_len); - pwep->KeyLength = wep_key_len; pwep->Length = wep_total_len; @@ -2142,12 +2140,10 @@ static int rtw_wx_set_enc_ext(struct net_device *dev, int ret = 0; param_len = sizeof(struct ieee_param) + pext->key_len; - param = rtw_malloc(param_len); + param = kzalloc(param_len, GFP_KERNEL); if (param == NULL) return -1; - memset(param, 0, param_len); - param->cmd = IEEE_CMD_SET_ENCRYPTION; memset(param->sta_addr, 0xff, ETH_ALEN); @@ -3513,14 +3509,12 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param, if (wep_key_len > 0) { wep_key_len = wep_key_len <= 5 ? 5 : 13; wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial); - pwep = rtw_malloc(wep_total_len); + pwep = kzalloc(wep_total_len, GFP_KERNEL); if (pwep == NULL) { DBG_871X(" r871x_set_encryption: pwep allocate fail !!!\n"); goto exit; } - memset(pwep, 0, wep_total_len); - pwep->KeyLength = wep_key_len; pwep->Length = wep_total_len; -- 2.7.4