From: 21cnbao@gmail.com (21cnbao at gmail.com)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] usb: chipidea: udc: fix potential kernel panic
Date: Tue, 4 Jun 2013 20:17:57 +0800 [thread overview]
Message-ID: <1370348277-24709-1-git-send-email-21cnbao@gmail.com> (raw)
In-Reply-To: <y>
From: Rong Wang <Rong.Wang@csr.com>
If global_phy is used when CONFIG_USB_PHY is not defined,
usb_get_phy() returns ERR_PTR(-ENXIO). If we only check
ci->transceiver is NULL or not in vbus_draw callback, it
will return true and continue to dereference ERR_PTR(-ENXIO)
which will cause a kernel panic.
Tested on CSR SiRFatlasVI SoC platform which licensed chipidea.
Signed-off-by: Rong Wang <Rong.Wang@csr.com>
Signed-off-by: Barry Song <Baohua.Song@csr.com>
---
drivers/usb/chipidea/udc.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 519ead2..822194b 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -1392,7 +1392,7 @@ static int ci13xxx_vbus_draw(struct usb_gadget *_gadget, unsigned mA)
{
struct ci13xxx *ci = container_of(_gadget, struct ci13xxx, gadget);
- if (ci->transceiver)
+ if (!IS_ERR_OR_NULL(ci->transceiver))
return usb_phy_set_power(ci->transceiver, mA);
return -ENOTSUPP;
}
@@ -1682,8 +1682,9 @@ static int udc_start(struct ci13xxx *ci)
ci->transceiver = usb_get_phy(USB_PHY_TYPE_USB2);
if (ci->platdata->flags & CI13XXX_REQUIRE_TRANSCEIVER) {
- if (ci->transceiver == NULL) {
- retval = -ENODEV;
+ if (IS_ERR_OR_NULL(ci->transceiver)) {
+ retval = ci->transceiver ?
+ PTR_ERR(ci->transceiver) : -ENODEV;
goto destroy_eps;
}
}
--
1.7.5.4
next reply other threads:[~2013-06-04 12:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-04 12:17 21cnbao at gmail.com [this message]
2013-08-02 3:13 ` [PATCH] usb: chipidea: udc: fix potential kernel panic Peter Chen
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=1370348277-24709-1-git-send-email-21cnbao@gmail.com \
--to=21cnbao@gmail.com \
--cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).