USB: gadget: android: Do not enable USB if usb_add_config fails

usb_add_config may fail while calling individual function's
bind_configs. This can happen if userspace tries to enable USB
before configuring the functions' parameters properly. Some
examples of such parameters are: DIAG transports and number of
RMNET instances.

Change-Id: I18380f2c6ddf4add0af66a1de62b0c5ae76ac6e4
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
diff --git a/drivers/usb/gadget/android.c b/drivers/usb/gadget/android.c
index 20b73a1..5e38238 100644
--- a/drivers/usb/gadget/android.c
+++ b/drivers/usb/gadget/android.c
@@ -1105,8 +1105,10 @@
 		cdev->desc.bDeviceClass = device_desc.bDeviceClass;
 		cdev->desc.bDeviceSubClass = device_desc.bDeviceSubClass;
 		cdev->desc.bDeviceProtocol = device_desc.bDeviceProtocol;
-		usb_add_config(cdev, &android_config_driver,
-					android_bind_config);
+		if (usb_add_config(cdev, &android_config_driver,
+							android_bind_config))
+			return size;
+
 		usb_gadget_connect(cdev->gadget);
 		dev->enabled = true;
 	} else if (!enabled && dev->enabled) {