summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPreetham Chandru <pchandru@nvidia.com>2012-05-02 19:02:58 +0530
committerMatthew Pedro <mapedro@nvidia.com>2012-05-14 08:20:16 -0700
commite0cb07ee13cdc50cc4dd1fb6590c2564337dd18d (patch)
tree66fab8d0e89290f8c6480bede606167318cb72b9
parent5d5d968f15e3304c6ae913e1b09424f5cd93ebe8 (diff)
usb: gadget: udc-core: fix kernel crash on soft_connect and srp interfaces
We should not call dev_get_drvdata() as the driver data is never set. We should use container_of() as it is been used for other sysfs attributes. Without this change writing to the soft_connect or srp interfaces crashes the kernel because of null pointer dereference. Bug 975473 Signed-off-by: Preeham Chandru R <pchandru@nvidia.com> Change-Id: I45f6dab32f5435d518bd5b4fcdfafa54b9b89acd Reviewed-on: http://git-master/r/100238 (cherry picked from commit 446b1ef096686dade535c7316e536d3d743c0331) Reviewed-on: http://git-master/r/101997 Tested-by: Preetham Chandru <pchandru@nvidia.com> GVS: Gerrit_Virtual_Submit Reviewed-by: Matthew Pedro <mapedro@nvidia.com>
-rw-r--r--drivers/usb/gadget/udc-core.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/usb/gadget/udc-core.c b/drivers/usb/gadget/udc-core.c
index 05ba47214361..df5ad21f2379 100644
--- a/drivers/usb/gadget/udc-core.c
+++ b/drivers/usb/gadget/udc-core.c
@@ -344,7 +344,7 @@ EXPORT_SYMBOL_GPL(usb_gadget_unregister_driver);
static ssize_t usb_udc_srp_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t n)
{
- struct usb_udc *udc = dev_get_drvdata(dev);
+ struct usb_udc *udc = container_of(dev, struct usb_udc, dev);
if (sysfs_streq(buf, "1"))
usb_gadget_wakeup(udc->gadget);
@@ -356,7 +356,7 @@ static DEVICE_ATTR(srp, S_IWUSR, NULL, usb_udc_srp_store);
static ssize_t usb_udc_softconn_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t n)
{
- struct usb_udc *udc = dev_get_drvdata(dev);
+ struct usb_udc *udc = container_of(dev, struct usb_udc, dev);
if (sysfs_streq(buf, "connect")) {
usb_gadget_connect(udc->gadget);