usb: gsmd: Update port_count before opening SMD channel

Driver registers a platform driver to be notified when
the SMD channels are ready to be opened. If the SMD
channels can be opened at the time of platform device's
registration then probe function gets called immediately
and fails because port_count is not yet updated.

Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
diff --git a/drivers/usb/gadget/u_smd.c b/drivers/usb/gadget/u_smd.c
index 0e8f247..c0a20b0 100644
--- a/drivers/usb/gadget/u_smd.c
+++ b/drivers/usb/gadget/u_smd.c
@@ -861,12 +861,13 @@
 
 	for (i = 0; i < count; i++) {
 		mutex_init(&smd_ports[i].lock);
+		n_smd_ports++;
 		ret = gsmd_port_alloc(i, &coding);
 		if (ret) {
+			n_smd_ports--;
 			pr_err("%s: Unable to alloc port:%d\n", __func__, i);
 			goto free_smd_ports;
 		}
-		n_smd_ports++;
 	}
 
 	gsmd_debugfs_init();