lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180605122851.23912-2-yuehaibing@huawei.com>
Date:   Tue, 5 Jun 2018 20:28:46 +0800
From:   YueHaibing <yuehaibing@...wei.com>
To:     <davem@...emloft.net>
CC:     <netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
        <jcliburn@...il.com>, <chris.snook@...il.com>, <benve@...co.com>,
        <jdmason@...zu.us>, <chessman@....org>, <jes@...ined-monkey.org>,
        <rahul.verma@...ium.com>, YueHaibing <yuehaibing@...wei.com>
Subject: [PATCH net-next 1/6] net: hippi: use pci_zalloc_consistent

use pci_zalloc_consistent to remove unnecessary memset.
Also remove a local intermediate pointer 'tmpptr'.

Signed-off-by: YueHaibing <yuehaibing@...wei.com>
---
 drivers/net/hippi/rrunner.c | 28 +++++++++++-----------------
 1 file changed, 11 insertions(+), 17 deletions(-)

diff --git a/drivers/net/hippi/rrunner.c b/drivers/net/hippi/rrunner.c
index f411164..9de7d2a 100644
--- a/drivers/net/hippi/rrunner.c
+++ b/drivers/net/hippi/rrunner.c
@@ -93,7 +93,6 @@ static int rr_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	static int version_disp;
 	u8 pci_latency;
 	struct rr_private *rrpriv;
-	void *tmpptr;
 	dma_addr_t ring_dma;
 	int ret = -ENOMEM;
 
@@ -155,29 +154,26 @@ static int rr_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 		goto out;
 	}
 
-	tmpptr = pci_alloc_consistent(pdev, TX_TOTAL_SIZE, &ring_dma);
-	rrpriv->tx_ring = tmpptr;
+	rrpriv->tx_ring = pci_alloc_consistent(pdev, TX_TOTAL_SIZE, &ring_dma);
 	rrpriv->tx_ring_dma = ring_dma;
 
-	if (!tmpptr) {
+	if (!rrpriv->tx_ring) {
 		ret = -ENOMEM;
 		goto out;
 	}
 
-	tmpptr = pci_alloc_consistent(pdev, RX_TOTAL_SIZE, &ring_dma);
-	rrpriv->rx_ring = tmpptr;
+	rrpriv->rx_ring = pci_alloc_consistent(pdev, RX_TOTAL_SIZE, &ring_dma);
 	rrpriv->rx_ring_dma = ring_dma;
 
-	if (!tmpptr) {
+	if (!rrpriv->rx_ring) {
 		ret = -ENOMEM;
 		goto out;
 	}
 
-	tmpptr = pci_alloc_consistent(pdev, EVT_RING_SIZE, &ring_dma);
-	rrpriv->evt_ring = tmpptr;
+	rrpriv->evt_ring = pci_alloc_consistent(pdev, EVT_RING_SIZE, &ring_dma);
 	rrpriv->evt_ring_dma = ring_dma;
 
-	if (!tmpptr) {
+	if (!trrpriv->evt_ring) {
 		ret = -ENOMEM;
 		goto out;
 	}
@@ -1192,24 +1188,22 @@ static int rr_open(struct net_device *dev)
 		goto error;
 	}
 
-	rrpriv->rx_ctrl = pci_alloc_consistent(pdev,
-					       256 * sizeof(struct ring_ctrl),
-					       &dma_addr);
+	rrpriv->rx_ctrl = pci_zalloc_consistent(pdev,
+						256 * sizeof(struct ring_ctrl),
+						&dma_addr);
 	if (!rrpriv->rx_ctrl) {
 		ecode = -ENOMEM;
 		goto error;
 	}
 	rrpriv->rx_ctrl_dma = dma_addr;
-	memset(rrpriv->rx_ctrl, 0, 256*sizeof(struct ring_ctrl));
 
-	rrpriv->info = pci_alloc_consistent(pdev, sizeof(struct rr_info),
-					    &dma_addr);
+	rrpriv->info = pci_zalloc_consistent(pdev, sizeof(struct rr_info),
+					     &dma_addr);
 	if (!rrpriv->info) {
 		ecode = -ENOMEM;
 		goto error;
 	}
 	rrpriv->info_dma = dma_addr;
-	memset(rrpriv->info, 0, sizeof(struct rr_info));
 	wmb();
 
 	spin_lock_irqsave(&rrpriv->lock, flags);
-- 
2.7.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ