From: Greg KH <gregkh@linuxfoundation.org>
To: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Cc: hminas@synopsys.com, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] usb: dwc2: host: Check for error map
Date: Fri, 24 Dec 2021 09:48:05 +0100 [thread overview]
Message-ID: <YcWJRWpmLAmXrnry@kroah.com> (raw)
In-Reply-To: <20211224031842.1564705-1-jiasheng@iscas.ac.cn>
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
prev parent reply other threads:[~2021-12-24 8:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-24 3:18 [PATCH] usb: dwc2: host: Check for error map Jiasheng Jiang
2021-12-24 8:48 ` Greg KH [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YcWJRWpmLAmXrnry@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=hminas@synopsys.com \
--cc=jiasheng@iscas.ac.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox