All of lore.kernel.org
 help / color / mirror / Atom feed
From: Felipe Ferreri Tonello <eu@felipetonello.com>
To: linux-usb@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
	Peter Chen <Peter.Chen@freescale.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Felipe Balbi <balbi@ti.com>,
	Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Subject: Re: [PATCH 2/3] usb: chipidea: udc: improve error handling on ep_queue
Date: Tue, 27 Oct 2015 09:27:33 +0000	[thread overview]
Message-ID: <562F4385.2020101@felipetonello.com> (raw)
In-Reply-To: <1442597421-3641-2-git-send-email-eu@felipetonello.com>

Hi Peter,

Have you seen this patch? I saw that you didn't apply it to your tree,
so I wonder if it is good or do I have to change anything.

This patch is a bug fix for a memory leak, so it is quite important.

-- 
Felipe

On 18/09/15 18:30, eu@felipetonello.com wrote:
> From: "Felipe F. Tonello" <eu@felipetonello.com>
> 
> _ep_queue() didn't check for errors when using add_td_to_list()
> which can fail if dma_pool_alloc fails, thus causing a kernel
> panic when lastnode->ptr is NULL.
> 
> Signed-off-by: Felipe F. Tonello <eu@felipetonello.com>
> ---
> 
> Changes for v2:
>   - Use separate patch for cleanups.
> 
>  drivers/usb/chipidea/udc.c | 18 +++++++++++++-----
>  1 file changed, 13 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
> index c936c72..7169113e 100644
> --- a/drivers/usb/chipidea/udc.c
> +++ b/drivers/usb/chipidea/udc.c
> @@ -435,19 +435,27 @@ static int _hardware_enqueue(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq)
>  	if (hwreq->req.dma % PAGE_SIZE)
>  		pages--;
>  
> -	if (rest == 0)
> -		add_td_to_list(hwep, hwreq, 0);
> +	if (rest == 0) {
> +		ret = add_td_to_list(hwep, hwreq, 0);
> +		if (ret < 0)
> +			goto done;
> +	}
>  
>  	while (rest > 0) {
>  		unsigned count = min(hwreq->req.length - hwreq->req.actual,
>  					(unsigned)(pages * CI_HDRC_PAGE_SIZE));
> -		add_td_to_list(hwep, hwreq, count);
> +		ret = add_td_to_list(hwep, hwreq, count);
> +		if (ret < 0)
> +			goto done;
>  		rest -= count;
>  	}
>  
>  	if (hwreq->req.zero && hwreq->req.length
> -	    && (hwreq->req.length % hwep->ep.maxpacket == 0))
> -		add_td_to_list(hwep, hwreq, 0);
> +	    && (hwreq->req.length % hwep->ep.maxpacket == 0)) {
> +		ret = add_td_to_list(hwep, hwreq, 0);
> +		if (ret < 0)
> +			goto done;
> +	}
>  
>  	firstnode = list_first_entry(&hwreq->tds, struct td_node, td);
>  
> 

  parent reply	other threads:[~2015-10-27  9:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-18 17:30 [PATCH 1/3] usb: chipidea: udc: _ep_queue and _hw_queue cleanup eu
2015-09-18 17:30 ` [PATCH 2/3] usb: chipidea: udc: improve error handling on ep_queue eu
2015-10-22  1:41   ` Peter Chen
2015-10-27  9:27   ` Felipe Ferreri Tonello [this message]
2015-10-27  9:29     ` Peter Chen
2015-09-18 17:30 ` [PATCH 3/3] usb: gadget: f_midi: check for error on usb_ep_queue eu
2015-09-18 17:32   ` Felipe Tonello

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=562F4385.2020101@felipetonello.com \
    --to=eu@felipetonello.com \
    --cc=Peter.Chen@freescale.com \
    --cc=andrzej.p@samsung.com \
    --cc=balbi@ti.com \
    --cc=gregkh@linuxfoundation.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.