mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: John Keeping <john@metanate.com>
To: John Youn <johnyoun@synopsys.com>
Cc: John Keeping <john@metanate.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] usb: dwc2: gadget: avoid null dereference on incomplete transfer
Date: Mon, 14 Mar 2016 19:20:14 +0000	[thread overview]
Message-ID: <1457983214-4317-1-git-send-email-john@metanate.com> (raw)

Setting up a gadget with the uac2 function results in:

  Unable to handle kernel NULL pointer dereference at virtual address 00000058
  ...
  PC is at dwc2_hsotg_irq+0x7f0/0x908
  LR is at dwc2_hsotg_irq+0x4c/0x908
  Backtrace:
  [<c03cd5fc>] (dwc2_hsotg_irq) from [<c00814fc>] (handle_irq_event_percpu+0x130/0x3ec)
  [<c00813cc>] (handle_irq_event_percpu) from [<c0081800>] (handle_irq_event+0x48/0x6c)

In all other loops we already skip endpoints that are null, so do so
here as well.

Signed-off-by: John Keeping <john@metanate.com>
---
 drivers/usb/dwc2/gadget.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 0abf73c..df43ec0 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -2606,7 +2606,9 @@ irq_retry:
 		for (idx = 1; idx < hsotg->num_of_eps; idx++) {
 			hs_ep = hsotg->eps_in[idx];
 
-			if (!hs_ep->isochronous || hs_ep->has_correct_parity)
+			if (!hs_ep ||
+			    !hs_ep->isochronous ||
+			    hs_ep->has_correct_parity)
 				continue;
 
 			epctl_reg = DIEPCTL(idx);
@@ -2623,7 +2625,9 @@ irq_retry:
 		for (idx = 1; idx < hsotg->num_of_eps; idx++) {
 			hs_ep = hsotg->eps_out[idx];
 
-			if (!hs_ep->isochronous || hs_ep->has_correct_parity)
+			if (!hs_ep ||
+			    !hs_ep->isochronous ||
+			    hs_ep->has_correct_parity)
 				continue;
 
 			epctl_reg = DOEPCTL(idx);
-- 
2.7.0.226.gfe986fe

             reply	other threads:[~2016-03-14 19:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-14 19:20 John Keeping [this message]
2016-03-30 13:21 ` Felipe Balbi
2016-03-30 22:45   ` John Youn
2016-04-04 10:51     ` Felipe Balbi

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=1457983214-4317-1-git-send-email-john@metanate.com \
    --to=john@metanate.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=johnyoun@synopsys.com \
    --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

all inboxes | Powered by JetHome®