lkml.org 
[lkml]   [2021]   [Dec]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] usb: dwc2: host: Check for error map
On Fri, Dec 24, 2021 at 11:18:42AM +0800, Jiasheng Jiang wrote:
> 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@iscas.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
>

As I have said before, I am not going to be taking any changes from you
due to them not being correct and the resulting aftermath of them.

Please start out with doing work in the drivers/staging/ portion of the
kernel to learn kernel development better and get more experience before
going out into other areas which can cause problems to more people.

good luck,

greg k-h

\
 
 \ /
  Last update: 2021-12-24 09:48    [W:0.033 / U:0.064 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site