summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPreetham Chandru <pchandru@nvidia.com>2012-05-02 19:02:58 +0530
committerSimone Willett <swillett@nvidia.com>2012-05-09 11:31:58 -0700
commit446b1ef096686dade535c7316e536d3d743c0331 (patch)
tree7b724a5088829387f6a8e1af41ffdb067f1ebac1
parent8fbd140659857935fab495332e71b99486792b21 (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 Tested-by: Preetham Chandru <pchandru@nvidia.com> Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Rakesh Bodla <rbodla@nvidia.com> Reviewed-by: Kiran Adduri <kadduri@nvidia.com> Reviewed-by: Bitan Biswas <bbiswas@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);