usb: rndis: Avoid unwanted usb config access
Krishna Yarlagadda [Fri, 16 Mar 2012 09:31:50 +0000 (14:31 +0530)]
Request complete may be called when there is no valid usb config
Avoid access to config when not required.

Bug 949543

Signed-off-by: Krishna Yarlagadda <kyarlagadda@nvidia.com>
Reviewed-on: http://git-master/r/91151
(cherry picked from commit 08bc68164d0bd90c84a8ea82f87f9f44e4341df2)

Change-Id: I5969144aaa9bcffddefa7933d43bfd3690814fba
Reviewed-on: http://git-master/r/93816
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Krishna Yarlagadda <kyarlagadda@nvidia.com>
Tested-by: Krishna Yarlagadda <kyarlagadda@nvidia.com>
Reviewed-by: Venkat Moganty <vmoganty@nvidia.com>

drivers/usb/gadget/f_rndis.c

index b284cae..861bcec 100644 (file)
@@ -383,7 +383,6 @@ static void rndis_response_available(void *_rndis)
 {
        struct f_rndis                  *rndis = _rndis;
        struct usb_request              *req = rndis->notify_req;
-       struct usb_composite_dev        *cdev = rndis->port.func.config->cdev;
        __le32                          *data = req->buf;
        int                             status;
 
@@ -401,14 +400,13 @@ static void rndis_response_available(void *_rndis)
        status = usb_ep_queue(rndis->notify, req, GFP_ATOMIC);
        if (status) {
                atomic_dec(&rndis->notify_count);
-               DBG(cdev, "notify/0 --> %d\n", status);
+               pr_err("notify/0 --> %d\n", status);
        }
 }
 
 static void rndis_response_complete(struct usb_ep *ep, struct usb_request *req)
 {
        struct f_rndis                  *rndis = req->context;
-       struct usb_composite_dev        *cdev = rndis->port.func.config->cdev;
        int                             status = req->status;
 
        /* after TX:
@@ -422,7 +420,7 @@ static void rndis_response_complete(struct usb_ep *ep, struct usb_request *req)
                atomic_set(&rndis->notify_count, 0);
                break;
        default:
-               DBG(cdev, "RNDIS %s response error %d, %d/%d\n",
+               pr_err("RNDIS %s response error %d, %d/%d\n",
                        ep->name, status,
                        req->actual, req->length);
                /* FALLTHROUGH */
@@ -438,7 +436,7 @@ static void rndis_response_complete(struct usb_ep *ep, struct usb_request *req)
                status = usb_ep_queue(rndis->notify, req, GFP_ATOMIC);
                if (status) {
                        atomic_dec(&rndis->notify_count);
-                       DBG(cdev, "notify/1 --> %d\n", status);
+                       pr_err("notify/1 --> %d\n", status);
                }
                break;
        }
@@ -447,14 +445,13 @@ static void rndis_response_complete(struct usb_ep *ep, struct usb_request *req)
 static void rndis_command_complete(struct usb_ep *ep, struct usb_request *req)
 {
        struct f_rndis                  *rndis = req->context;
-       struct usb_composite_dev        *cdev = rndis->port.func.config->cdev;
        int                             status;
 
        /* received RNDIS command from USB_CDC_SEND_ENCAPSULATED_COMMAND */
 //     spin_lock(&dev->lock);
        status = rndis_msg_parser(rndis->config, (u8 *) req->buf);
        if (status < 0)
-               ERROR(cdev, "RNDIS command error %d, %d/%d\n",
+               pr_err("RNDIS command error %d, %d/%d\n",
                        status, req->actual, req->length);
 //     spin_unlock(&dev->lock);
 }