drm/msm: fix crashes on probe failure

Fix issues that occur on the probe failure path. First, remove
an extraneous call to destroy the power handle client. Second,
upstream moved the location of the drm_dev_register call to be
last in the init sequence, as intended by that API. In failure
path we need to make sure to only call drm_dev_unregister if the
driver was previously registered. Moving the drm_drv_register
also requires changing sde_connector to avoid registering the
connector, which tries to create sysfs nodes, before the
drm_drv_regiter has created the overall sysfs root for the
device.

Change-Id: I18caae1d2b2fa2086d5b86676a250b2b06044081
Signed-off-by: Lloyd Atkinson <latkinso@codeaurora.org>
diff --git a/drivers/gpu/drm/msm/sde/sde_connector.c b/drivers/gpu/drm/msm/sde/sde_connector.c
index ac9997c..59db57a 100644
--- a/drivers/gpu/drm/msm/sde/sde_connector.c
+++ b/drivers/gpu/drm/msm/sde/sde_connector.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -526,23 +526,17 @@
 		goto error_cleanup_conn;
 	}
 
-	rc = drm_connector_register(&c_conn->base);
-	if (rc) {
-		SDE_ERROR("failed to register drm connector, %d\n", rc);
-		goto error_cleanup_fence;
-	}
-
 	rc = drm_mode_connector_attach_encoder(&c_conn->base, encoder);
 	if (rc) {
 		SDE_ERROR("failed to attach encoder to connector, %d\n", rc);
-		goto error_unregister_conn;
+		goto error_cleanup_fence;
 	}
 
 	if (c_conn->ops.set_backlight) {
 		rc = sde_backlight_setup(&c_conn->base);
 		if (rc) {
 			pr_err("failed to setup backlight, rc=%d\n", rc);
-			goto error_unregister_conn;
+			goto error_cleanup_fence;
 		}
 	}
 
@@ -557,7 +551,7 @@
 		if (!info) {
 			SDE_ERROR("failed to allocate info buffer\n");
 			rc = -ENOMEM;
-			goto error_unregister_conn;
+			goto error_cleanup_fence;
 		}
 
 		sde_kms_info_reset(info);
@@ -565,7 +559,7 @@
 		if (rc) {
 			SDE_ERROR("post-init failed, %d\n", rc);
 			kfree(info);
-			goto error_unregister_conn;
+			goto error_cleanup_fence;
 		}
 
 		msm_property_install_blob(&c_conn->property_info,
@@ -611,8 +605,6 @@
 	if (c_conn->blob_caps)
 		drm_property_unreference_blob(c_conn->blob_caps);
 	msm_property_destroy(&c_conn->property_info);
-error_unregister_conn:
-	drm_connector_unregister(&c_conn->base);
 error_cleanup_fence:
 	sde_fence_deinit(&c_conn->retire_fence);
 error_cleanup_conn: