Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2899804ybd; Thu, 27 Jun 2019 22:43:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqzzgwRwgXnPDQNdspV3rJA8iu8PljCGagSVq99P9CtrEeQJEWriJVaBJtLFeRJUTrtcVZL5 X-Received: by 2002:a17:902:7687:: with SMTP id m7mr9458644pll.310.1561700580891; Thu, 27 Jun 2019 22:43:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561700580; cv=none; d=google.com; s=arc-20160816; b=0s+g6G1ZX5hOogZtvZJgZwhKlxLqkpqXL0aSh3GnQiyUHiVukSgKIHjS237ABOiGZl QDrEoIxeCLJClXtTLNE0W7df9oAIOZNa8o65t60r1SaBHc+4P+z68FkqEIUvT5J1Kxg3 dBmBa8KIFn1Xyt+4oHkFTP0tppS+dR4iJA0PeFkN8hSmWrIHeDclMhAZYbA4yLO01nl0 ANx+G2oaNcSk1p3GlYgl2RFWoFAIOjbbSucHFzDoDMEkX2amaG40TURkyWKGI0slUhFP 4YYmaC1Qn6xDZETPInagXwR8uW+xLhEt1ZoxPoKzI735SPWX04FfJ+VCsMKVf7aIwAXd Tizw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=5H4vCB3h2ez6fsn8ibBjVxfkyhz6x76JXGxi9S+S/Vg=; b=RwKs6ajozXj4Nq/oI2rGHU7U4aLUMVQpwTxLkDgjHWqIKINtQ8C7NlnpxkRJZ+xMc8 YvoYTGruTig20EYg3GZalD5kah7mbcOrRW5jgp+4ceT4R6c47Ytuaj7vIF76H20eNw7S YkpYfR69xLJeJ9BSqVDEMOBbuIWsfOiWE19JvgKYWfQDDC2ywizHrLps5Vyznsf2QccD 6oA1d1HHpQtIXxdOxMnDsciwoI0QrWIds57yznE1oBVN0by24XujXjgHRg7vOXTeEs/n iqkwygYThX3yKo83q3LgYuCIjEkbQyhJRlgdBgUtDclIgSnYEAPcNVRw7SAZ9vE6WgXU quqg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f4si1218091plb.38.2019.06.27.22.42.44; Thu, 27 Jun 2019 22:43:00 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726880AbfF1Fl0 (ORCPT + 99 others); Fri, 28 Jun 2019 01:41:26 -0400 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:9790 "EHLO mail3-relais-sop.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726566AbfF1FlZ (ORCPT ); Fri, 28 Jun 2019 01:41:25 -0400 X-IronPort-AV: E=Sophos;i="5.63,426,1557180000"; d="scan'208";a="311715816" Received: from abo-12-105-68.mrs.modulonet.fr (HELO hadrien) ([85.68.105.12]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Jun 2019 07:41:21 +0200 Date: Fri, 28 Jun 2019 07:41:21 +0200 (CEST) From: Julia Lawall X-X-Sender: jll@hadrien To: Fuqian Huang cc: Larry Finger , Greg Kroah-Hartman , Florian Schilhabel , Michael Straube , Julia Lawall , Dafna Hirschfeld , Omer Efrat , Quytelda Kahja , Arnd Bergmann , Mamta Shukla , Emanuel Bennici , Wen Yang , Payal Kshirsagar , Jia-Ju Bai , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 19/27] staging: rtl8*: use zeroing allocator rather than allocator followed with memset 0 In-Reply-To: <20190628024935.15806-1-huangfq.daxian@gmail.com> Message-ID: References: <20190628024935.15806-1-huangfq.daxian@gmail.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 28 Jun 2019, Fuqian Huang wrote: > Use zeroing allocator rather than allocator followed with memset 0. Maybe it would be better to just change these to the appropriate kmalloc and kzalloc calls. You will need to check on whether locks are held to know whether the secon argument should be GFP_ATOMIC or GFP_KERNEL. The current code doesn't address this issue in a correct manner. You may also want to add some options to your get_maintainer call to not send patches to everyone who has ever worked on the driver. julia > > Signed-off-by: Fuqian Huang > --- > drivers/staging/rtl8188eu/os_dep/mlme_linux.c | 3 +-- > drivers/staging/rtl8712/rtl871x_io.c | 4 +--- > drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 8 ++------ > drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 12 +++--------- > 4 files changed, 7 insertions(+), 20 deletions(-) > > diff --git a/drivers/staging/rtl8188eu/os_dep/mlme_linux.c b/drivers/staging/rtl8188eu/os_dep/mlme_linux.c > index 9db11b16cb93..250acb01d1a9 100644 > --- a/drivers/staging/rtl8188eu/os_dep/mlme_linux.c > +++ b/drivers/staging/rtl8188eu/os_dep/mlme_linux.c > @@ -98,10 +98,9 @@ void rtw_report_sec_ie(struct adapter *adapter, u8 authmode, u8 *sec_ie) > if (authmode == _WPA_IE_ID_) { > RT_TRACE(_module_mlme_osdep_c_, _drv_info_, > ("rtw_report_sec_ie, authmode=%d\n", authmode)); > - buff = rtw_malloc(IW_CUSTOM_MAX); > + buff = rtw_zmalloc(IW_CUSTOM_MAX); > if (!buff) > return; > - memset(buff, 0, IW_CUSTOM_MAX); > p = buff; > p += sprintf(p, "ASSOCINFO(ReqIEs ="); > len = sec_ie[1] + 2; > diff --git a/drivers/staging/rtl8712/rtl871x_io.c b/drivers/staging/rtl8712/rtl871x_io.c > index 17dafeffd6f4..87024d6a465e 100644 > --- a/drivers/staging/rtl8712/rtl871x_io.c > +++ b/drivers/staging/rtl8712/rtl871x_io.c > @@ -107,13 +107,11 @@ uint r8712_alloc_io_queue(struct _adapter *adapter) > INIT_LIST_HEAD(&pio_queue->processing); > INIT_LIST_HEAD(&pio_queue->pending); > spin_lock_init(&pio_queue->lock); > - pio_queue->pallocated_free_ioreqs_buf = kmalloc(NUM_IOREQ * > + pio_queue->pallocated_free_ioreqs_buf = kzalloc(NUM_IOREQ * > (sizeof(struct io_req)) + 4, > GFP_ATOMIC); > if ((pio_queue->pallocated_free_ioreqs_buf) == NULL) > goto alloc_io_queue_fail; > - memset(pio_queue->pallocated_free_ioreqs_buf, 0, > - (NUM_IOREQ * (sizeof(struct io_req)) + 4)); > pio_queue->free_ioreqs_buf = pio_queue->pallocated_free_ioreqs_buf + 4 > - ((addr_t)(pio_queue->pallocated_free_ioreqs_buf) > & 3); > diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c > index db553f2e4c0b..f8e0723f5d1f 100644 > --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c > +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c > @@ -1078,12 +1078,10 @@ static int cfg80211_rtw_add_key(struct wiphy *wiphy, struct net_device *ndev, > DBG_871X("pairwise =%d\n", pairwise); > > param_len = sizeof(struct ieee_param) + params->key_len; > - param = rtw_malloc(param_len); > + param = rtw_zmalloc(param_len); > if (param == NULL) > return -1; > > - memset(param, 0, param_len); > - > param->cmd = IEEE_CMD_SET_ENCRYPTION; > memset(param->sta_addr, 0xff, ETH_ALEN); > > @@ -2167,15 +2165,13 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev, > { > 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 = rtw_zmalloc(wep_total_len); > if (pwep == NULL) { > DBG_871X(" wpa_set_encryption: pwep allocate fail !!!\n"); > ret = -ENOMEM; > goto exit; > } > > - memset(pwep, 0, wep_total_len); > - > pwep->KeyLength = wep_key_len; > pwep->Length = wep_total_len; > > diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c > index e3d356952875..1491d420929c 100644 > --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c > +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c > @@ -478,14 +478,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 = rtw_zmalloc(wep_total_len); > 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; > > @@ -2144,12 +2142,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 = rtw_zmalloc(param_len); > if (param == NULL) > return -1; > > - memset(param, 0, param_len); > - > param->cmd = IEEE_CMD_SET_ENCRYPTION; > memset(param->sta_addr, 0xff, ETH_ALEN); > > @@ -3522,14 +3518,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 = rtw_zmalloc(wep_total_len); > 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.11.0 > >