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: <20211224031842.1564705-1-jiasheng@iscas.ac.cn>
Date:   Fri, 24 Dec 2021 11:18:42 +0800
From:   Jiasheng Jiang <jiasheng@...as.ac.cn>
To:     hminas@...opsys.com, gregkh@...uxfoundation.org
Cc:     linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org,
        Jiasheng Jiang <jiasheng@...as.ac.cn>
Subject: [PATCH] usb: dwc2: host: Check for error map

For the possible failure of the dma_map_single(), it should be better to
check the return map address by using dma_mapping_error() to guarantee
the valid of the map address.

Fixes: 197ba5f406cc ("Move DWC2 driver out of staging")
Signed-off-by: Jiasheng Jiang <jiasheng@...as.ac.cn>
---
 drivers/usb/dwc2/hcd_ddma.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/dwc2/hcd_ddma.c b/drivers/usb/dwc2/hcd_ddma.c
index a858b5f9c1d6..89ed93a67c8a 100644
--- a/drivers/usb/dwc2/hcd_ddma.c
+++ b/drivers/usb/dwc2/hcd_ddma.c
@@ -143,6 +143,7 @@ static void dwc2_desc_list_free(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh)
 
 static int dwc2_frame_list_alloc(struct dwc2_hsotg *hsotg, gfp_t mem_flags)
 {
+	dma_addr_t addr;
 	if (hsotg->frame_list)
 		return 0;
 
@@ -151,9 +152,13 @@ static int dwc2_frame_list_alloc(struct dwc2_hsotg *hsotg, gfp_t mem_flags)
 	if (!hsotg->frame_list)
 		return -ENOMEM;
 
-	hsotg->frame_list_dma = dma_map_single(hsotg->dev, hsotg->frame_list,
-					       hsotg->frame_list_sz,
-					       DMA_TO_DEVICE);
+	addr = dma_map_single(hsotg->dev, hsotg->frame_list,
+			      hsotg->frame_list_sz,
+			      DMA_TO_DEVICE);
+	if (dma_mapping_error(hsotg->dev, addr))
+		return -ENOMEM;
+
+	hsotg->frame_list_dma = addr;
 
 	return 0;
 }
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ