Linux USB
 help / color / mirror / Atom feed
From: Sergei Shtylyov <sergei.shtylyov@gmail.com>
To: Prashanth K <quic_prashk@quicinc.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Mathias Nyman <mathias.nyman@intel.com>
Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH] usb: xhci: Add error handling in xhci_map_urb_for_dma
Date: Wed, 28 Feb 2024 12:01:06 +0300	[thread overview]
Message-ID: <e4f87b6b-4561-8058-3449-2ff9086c81a4@gmail.com> (raw)
In-Reply-To: <20240228083343.3101303-1-quic_prashk@quicinc.com>

On 2/28/24 11:33 AM, Prashanth K wrote:

> Currently xhci_map_urb_for_dma() creates a temporary buffer
> and copies the SG list to the new linear buffer. But if the
> kzalloc_node() fails, then the following sg_pcopy_to_buffer()
> can lead to crash since it tries to memcpy to NULL pointer.
> So return -EAGAIN if kzalloc returns null pointer.
> 
> Cc: <stable@vger.kernel.org> # 5.11
> Fixes: 2017a1e58472 ("usb: xhci: Use temporary buffer to consolidate SG")
> Signed-off-by: Prashanth K <quic_prashk@quicinc.com>
> ---
>  drivers/usb/host/xhci.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
> index c057c42c36f4..0597a60bec34 100644
> --- a/drivers/usb/host/xhci.c
> +++ b/drivers/usb/host/xhci.c
> @@ -1218,6 +1218,9 @@ static int xhci_map_temp_buffer(struct usb_hcd *hcd, struct urb *urb)
>  	temp = kzalloc_node(buf_len, GFP_ATOMIC,
>  			    dev_to_node(hcd->self.sysdev));
>  

   I don't think we need an empty line here.

> +	if (!temp)
> +		return -EAGAIN;

   Not -ENOMEM?

> +
>  	if (usb_urb_dir_out(urb))
>  		sg_pcopy_to_buffer(urb->sg, urb->num_sgs,
>  				   temp, buf_len, 0);

MBR, Sergey

  reply	other threads:[~2024-02-28  9:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-28  8:33 [PATCH] usb: xhci: Add error handling in xhci_map_urb_for_dma Prashanth K
2024-02-28  9:01 ` Sergei Shtylyov [this message]
2024-02-28 10:12   ` Prashanth K

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=e4f87b6b-4561-8058-3449-2ff9086c81a4@gmail.com \
    --to=sergei.shtylyov@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@intel.com \
    --cc=quic_prashk@quicinc.com \
    --cc=stable@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