From: Peter Chen <peter.chen@freescale.com>
To: <eu@felipetonello.com>
Cc: <linux-usb@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
"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: Thu, 22 Oct 2015 09:41:28 +0800 [thread overview]
Message-ID: <20151022014126.GA5624@shlinux2> (raw)
In-Reply-To: <1442597421-3641-2-git-send-email-eu@felipetonello.com>
On Fri, Sep 18, 2015 at 06:30:20PM +0100, 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);
>
> --
> 2.1.4
>
Hi Felipe,
I can't apply it in my tree, would you please create it based on chipdea
tree?
https://git.kernel.org/pub/scm/linux/kernel/git/peter.chen/usb.git
branch: ci-for-usb-next
--
Best Regards,
Peter Chen
next prev parent reply other threads:[~2015-10-22 1:42 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 [this message]
2015-10-27 9:27 ` Felipe Ferreri Tonello
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=20151022014126.GA5624@shlinux2 \
--to=peter.chen@freescale.com \
--cc=andrzej.p@samsung.com \
--cc=balbi@ti.com \
--cc=eu@felipetonello.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox