Re: [PATCH] usb: cdns2: fix possible null-ptr-deref in cdns2_gadget_ep_queue()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Oct 28, 2024 at 03:50:28AM +0000, Yi Yang wrote:
> The cdns2_gadget_ep_alloc_request() will return NULL when kzalloc() fails,
> fix possible null-ptr-deref by check return value.
> 
> Fixes: 3eb1f1efe204 ("usb: cdns2: Add main part of Cadence USBHS driver")
> Signed-off-by: Yi Yang <yiyang13@xxxxxxxxxx>
> ---
>  drivers/usb/gadget/udc/cdns2/cdns2-gadget.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/usb/gadget/udc/cdns2/cdns2-gadget.c b/drivers/usb/gadget/udc/cdns2/cdns2-gadget.c
> index 62fce42ef2da..c06a50af268e 100644
> --- a/drivers/usb/gadget/udc/cdns2/cdns2-gadget.c
> +++ b/drivers/usb/gadget/udc/cdns2/cdns2-gadget.c
> @@ -1724,6 +1724,10 @@ static int cdns2_gadget_ep_queue(struct usb_ep *ep, struct usb_request *request,
>  		struct cdns2_request *preq;
>  
>  		zlp_request = cdns2_gadget_ep_alloc_request(ep, GFP_ATOMIC);
> +		if (!zlp_request) {
> +			spin_unlock_irqrestore(&pdev->lock, flags);
> +			return -ENOMEM;
> +		}
>  		zlp_request->buf = pdev->zlp_buf;
>  		zlp_request->length = 0;
>  
> -- 
> 2.25.1
> 
> 

How was this tested to verify it works properly?

thanks,

greg k-h




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux