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-next>] [day] [month] [year] [list]
Message-ID: <1653374469-30555-1-git-send-email-baihaowen@meizu.com>
Date:   Tue, 24 May 2022 14:41:08 +0800
From:   Haowen Bai <baihaowen@...zu.com>
To:     Veerasenareddy Burru <vburru@...vell.com>,
        Abhijit Ayarekar <aayarekar@...vell.com>,
        "David S. Miller" <davem@...emloft.net>,
        "Eric Dumazet" <edumazet@...gle.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>
CC:     Haowen Bai <baihaowen@...zu.com>, <netdev@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>
Subject: [PATCH V3] octeon_ep: Remove unnecessary cast

./drivers/net/ethernet/marvell/octeon_ep/octep_rx.c:161:18-40: WARNING:
casting value returned by memory allocation function to (struct
octep_rx_buffer *) is useless.

and we do more optimization:
1. remove casting value
2. use obvious size
3. use kvcalloc instead of vzalloc

Signed-off-by: Haowen Bai <baihaowen@...zu.com>
---
V1->V2: change vzalloc to vcalloc as suggestion.
V2->V3: use obvious size; use kvcalloc instead of vzalloc.

 drivers/net/ethernet/marvell/octeon_ep/octep_rx.c | 8 ++++----
 drivers/net/ethernet/marvell/octeon_ep/octep_rx.h | 2 --
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_rx.c b/drivers/net/ethernet/marvell/octeon_ep/octep_rx.c
index d9ae0937d17a..d6a0da61db44 100644
--- a/drivers/net/ethernet/marvell/octeon_ep/octep_rx.c
+++ b/drivers/net/ethernet/marvell/octeon_ep/octep_rx.c
@@ -158,8 +158,8 @@ static int octep_setup_oq(struct octep_device *oct, int q_no)
 		goto desc_dma_alloc_err;
 	}
 
-	oq->buff_info = (struct octep_rx_buffer *)
-			vzalloc(oq->max_count * OCTEP_OQ_RECVBUF_SIZE);
+	oq->buff_info = kvcalloc(oq->max_count, sizeof(struct octep_rx_buffer),
+				 GFP_KERNEL);
 	if (unlikely(!oq->buff_info)) {
 		dev_err(&oct->pdev->dev,
 			"Failed to allocate buffer info for OQ-%d\n", q_no);
@@ -176,7 +176,7 @@ static int octep_setup_oq(struct octep_device *oct, int q_no)
 	return 0;
 
 oq_fill_buff_err:
-	vfree(oq->buff_info);
+	kvfree(oq->buff_info);
 	oq->buff_info = NULL;
 buf_list_err:
 	dma_free_coherent(oq->dev, desc_ring_size,
@@ -230,7 +230,7 @@ static int octep_free_oq(struct octep_oq *oq)
 
 	octep_oq_free_ring_buffers(oq);
 
-	vfree(oq->buff_info);
+	kvfree(oq->buff_info);
 
 	if (oq->desc_ring)
 		dma_free_coherent(oq->dev,
diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_rx.h b/drivers/net/ethernet/marvell/octeon_ep/octep_rx.h
index 782a24f27f3e..34a32d95cd4b 100644
--- a/drivers/net/ethernet/marvell/octeon_ep/octep_rx.h
+++ b/drivers/net/ethernet/marvell/octeon_ep/octep_rx.h
@@ -67,8 +67,6 @@ struct octep_rx_buffer {
 	u64 len;
 };
 
-#define OCTEP_OQ_RECVBUF_SIZE    (sizeof(struct octep_rx_buffer))
-
 /* Output Queue statistics. Each output queue has four stats fields. */
 struct octep_oq_stats {
 	/* Number of packets received from the Device. */
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ