Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2782287ybd; Thu, 27 Jun 2019 19:50:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqwzN+LSkJXDQoy6qUxQ5T5itYuXNrhVe7uRRqNw+HmyviJgAhLn40CymGj5y10pmaD8RRfw X-Received: by 2002:a65:510c:: with SMTP id f12mr6734868pgq.92.1561690207633; Thu, 27 Jun 2019 19:50:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561690207; cv=none; d=google.com; s=arc-20160816; b=0ltv+Fb0ylkKL4TK24J7rXRpXVftw59i+CjA8SNPFUp8KzVICwCaZsCUnEXQH6reeB D4Nzttgfq68clm7yTV/TRRGvGtgmvDWH7oEe1gSOH6/uLe+DJpDB3wknwjZK8sHsyb3E tQ8j5mqrZlkgBwn9ntjOP5D5uX9FN5xjrwsi+NNGwjdRwqyHW2nVEh1fejvsnZU4apTu HNumDe/8kuR7olY8bzyFhGOQW1ajBe10W+yMp1xJKfG7VA2fClXX1p+3MMCm8zLg7HLf oBor9Tx+YMxAebQ+1F0UXS2BN9N14HXTjtK39UEzx2FZaaS1lg9swq/3nOsNU+4mncgi 2POA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:message-id:date:subject:cc:from :dkim-signature; bh=BjZs4QmT9Rq6xJfvVoRrPidd5HcnRoBaVWi/hg75COg=; b=OXYC0RNpbnwBiTbxiyIFahjpLKf9y8GUg2DNQbHEixnL5Uozz0WS7v+uUwr7vf88CE Xs09gfSkdXhoK/Q3qcZiwUbEcvmCz2sjxMUIvizARmOHz0Tb9RPUKH4FJtYRFezD9Vad 0NtpjiYorURZTTQVmj6rvePxQIYMvL1qDUedJ1a+1XM8BkP9K3JV55p8OdBfPkuEX2xB 5bfHGthgDfzxD56SO2XfVZSGTfe68hb+dPmdGHwpvgiBkns1uEAstEOA47FilNzFxVh3 1BCrYN4emVDNL3TFkwOuY3qbpYlT4lfPfSBdfMaon2hlqIJRCl4dT7GO6EiCrbsAoo2q qvWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=XUmdL4kU; 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=fail (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 j7si889697pgq.504.2019.06.27.19.49.52; Thu, 27 Jun 2019 19:50:07 -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=fail header.i=@gmail.com header.s=20161025 header.b=XUmdL4kU; 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727113AbfF1Ctq (ORCPT + 99 others); Thu, 27 Jun 2019 22:49:46 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:42828 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726441AbfF1Ctq (ORCPT ); Thu, 27 Jun 2019 22:49:46 -0400 Received: by mail-pf1-f196.google.com with SMTP id q10so2186079pff.9 for ; Thu, 27 Jun 2019 19:49:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=BjZs4QmT9Rq6xJfvVoRrPidd5HcnRoBaVWi/hg75COg=; b=XUmdL4kUPfZgTYfBdqlqn0WkAet+SkaoA+caF+woKXYmNDKQ9vsgqvdsOThS+Va4J9 84qyPrmEHSvP0yh8znX08527pWn/XH1bntADASOLRGw8DOqzGjwK+cJQk5wpuGKjv9GG AJHFf3fjm2bLMrLnOgBtPw9bnZ13jflSB1h388xemN3Ad59kR5Q6MmSCQWM3Urk5WaOT EnDTeFN5/A5rtqNkwsGOLP7XWtnLPK01XW0Fx+L/kx7/7QGbYGNzr8vA+Huqln5QbatT Hns6EW28DT5Vzva24YZH5PEMvq7RfKe7IYMc/T4jzwIQ5xRbWn0qm9H1fbcA9yzQeFu+ yJHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=BjZs4QmT9Rq6xJfvVoRrPidd5HcnRoBaVWi/hg75COg=; b=HWok6eRQ7dcQyKcH39Ao5NdhOPn3CMBfUWKSgPBHAmo4gCPF0FyVlf119o08eCzHnf OH2VSUBQ9QpSHnu5vvn0Yu00UL7P0IybdEy1Cdn5W2qntOji5E0W8h1gf5lNR8IKifDT RZ7W/mreAXGojzZKNIB7+DuaogZkE3n8dwnZWPoVptxklDdWpQKl3F2O3sK+KnKuKMq7 9kE6hUlv26Koorx71Smcur695YHDsKNakoYcBIoG0DzzrI+IMx53l1WvfB1n5kezAcrr l1Og0SFybNx9ez8UW0++z6mghZOE8r96rBUdmFF2Vkum6+d+ERiPJkYPyO45AcKOdo2M lY8g== X-Gm-Message-State: APjAAAX1jIu8MJzIn55cg4At6iZ7K3PhbhvyP29mpi+T3v9GKjlW1LGi AqFmd7MN1IxA+5FNiyDhUio= X-Received: by 2002:a17:90a:cd04:: with SMTP id d4mr10368889pju.128.1561690185607; Thu, 27 Jun 2019 19:49:45 -0700 (PDT) Received: from hfq-skylake.ipads-lab.se.sjtu.edu.cn ([202.120.40.82]) by smtp.googlemail.com with ESMTPSA id w1sm562908pjt.30.2019.06.27.19.49.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Jun 2019 19:49:45 -0700 (PDT) From: Fuqian Huang Cc: Fuqian Huang , 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: [PATCH v2 19/27] staging: rtl8*: use zeroing allocator rather than allocator followed with memset 0 Date: Fri, 28 Jun 2019 10:49:29 +0800 Message-Id: <20190628024935.15806-1-huangfq.daxian@gmail.com> X-Mailer: git-send-email 2.11.0 To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use zeroing allocator rather than allocator followed with memset 0. 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