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: <20220513173400.3848271-2-ricardo.martinez@linux.intel.com>
Date:   Fri, 13 May 2022 10:33:59 -0700
From:   Ricardo Martinez <ricardo.martinez@...ux.intel.com>
To:     netdev@...r.kernel.org, linux-wireless@...r.kernel.org
Cc:     kuba@...nel.org, davem@...emloft.net, johannes@...solutions.net,
        ryazanov.s.a@...il.com, loic.poulain@...aro.org,
        m.chetan.kumar@...el.com, chandrashekar.devegowda@...el.com,
        linuxwwan@...el.com, chiranjeevi.rapolu@...ux.intel.com,
        haijun.liu@...iatek.com, andriy.shevchenko@...ux.intel.com,
        dinesh.sharma@...el.com, ilpo.jarvinen@...ux.intel.com,
        moises.veleta@...el.com, sreehari.kancharla@...el.com,
        Ricardo Martinez <ricardo.martinez@...ux.intel.com>
Subject: [PATCH net-next 1/2] net: wwan: t7xx: Avoid calls to skb_data_area_size()

skb_data_area_size() helper was used to calculate the size of the
DMA mapped buffer passed to the HW. Instead of doing this, use the
size passed to allocate the skbs.

Signed-off-by: Ricardo Martinez <ricardo.martinez@...ux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
---
 drivers/net/wwan/t7xx/t7xx_hif_cldma.c     | 7 +++----
 drivers/net/wwan/t7xx/t7xx_hif_dpmaif_rx.c | 6 ++----
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wwan/t7xx/t7xx_hif_cldma.c b/drivers/net/wwan/t7xx/t7xx_hif_cldma.c
index 46066dcd2607..0c52801ed0de 100644
--- a/drivers/net/wwan/t7xx/t7xx_hif_cldma.c
+++ b/drivers/net/wwan/t7xx/t7xx_hif_cldma.c
@@ -97,8 +97,7 @@ static int t7xx_cldma_alloc_and_map_skb(struct cldma_ctrl *md_ctrl, struct cldma
 	if (!req->skb)
 		return -ENOMEM;
 
-	req->mapped_buff = dma_map_single(md_ctrl->dev, req->skb->data,
-					  skb_data_area_size(req->skb), DMA_FROM_DEVICE);
+	req->mapped_buff = dma_map_single(md_ctrl->dev, req->skb->data, size, DMA_FROM_DEVICE);
 	if (dma_mapping_error(md_ctrl->dev, req->mapped_buff)) {
 		dev_kfree_skb_any(req->skb);
 		req->skb = NULL;
@@ -154,7 +153,7 @@ static int t7xx_cldma_gpd_rx_from_q(struct cldma_queue *queue, int budget, bool
 
 		if (req->mapped_buff) {
 			dma_unmap_single(md_ctrl->dev, req->mapped_buff,
-					 skb_data_area_size(skb), DMA_FROM_DEVICE);
+					 queue->tr_ring->pkt_size, DMA_FROM_DEVICE);
 			req->mapped_buff = 0;
 		}
 
@@ -376,7 +375,7 @@ static void t7xx_cldma_ring_free(struct cldma_ctrl *md_ctrl,
 	list_for_each_entry_safe(req_cur, req_next, &ring->gpd_ring, entry) {
 		if (req_cur->mapped_buff && req_cur->skb) {
 			dma_unmap_single(md_ctrl->dev, req_cur->mapped_buff,
-					 skb_data_area_size(req_cur->skb), tx_rx);
+					 ring->pkt_size, tx_rx);
 			req_cur->mapped_buff = 0;
 		}
 
diff --git a/drivers/net/wwan/t7xx/t7xx_hif_dpmaif_rx.c b/drivers/net/wwan/t7xx/t7xx_hif_dpmaif_rx.c
index 35a8a0d7c1ee..91a0eb19e0d8 100644
--- a/drivers/net/wwan/t7xx/t7xx_hif_dpmaif_rx.c
+++ b/drivers/net/wwan/t7xx/t7xx_hif_dpmaif_rx.c
@@ -151,14 +151,12 @@ static bool t7xx_alloc_and_map_skb_info(const struct dpmaif_ctrl *dpmaif_ctrl,
 {
 	dma_addr_t data_bus_addr;
 	struct sk_buff *skb;
-	size_t data_len;
 
 	skb = __dev_alloc_skb(size, GFP_KERNEL);
 	if (!skb)
 		return false;
 
-	data_len = skb_data_area_size(skb);
-	data_bus_addr = dma_map_single(dpmaif_ctrl->dev, skb->data, data_len, DMA_FROM_DEVICE);
+	data_bus_addr = dma_map_single(dpmaif_ctrl->dev, skb->data, size, DMA_FROM_DEVICE);
 	if (dma_mapping_error(dpmaif_ctrl->dev, data_bus_addr)) {
 		dev_err_ratelimited(dpmaif_ctrl->dev, "DMA mapping error\n");
 		dev_kfree_skb_any(skb);
@@ -167,7 +165,7 @@ static bool t7xx_alloc_and_map_skb_info(const struct dpmaif_ctrl *dpmaif_ctrl,
 
 	cur_skb->skb = skb;
 	cur_skb->data_bus_addr = data_bus_addr;
-	cur_skb->data_len = data_len;
+	cur_skb->data_len = size;
 
 	return true;
 }
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ