drm/i915: use error path
authorSudip Mukherjee <sudipm.mukherjee@gmail.com>
Thu, 8 Oct 2015 13:57:59 +0000 (19:27 +0530)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Thu, 8 Oct 2015 14:30:13 +0000 (16:30 +0200)
Use goto to handle the error path to avoid duplicating the same code. In
the error path intel_dig_port is the last one to be released as it was
the first one to be allocated and ideally the error path should be the
reverse of the execution path.

Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/intel_dp.c

index 8d34ca7b287ad01fb7378b995d35d0dbe35ecebc..18bcfbe0b8ba02edd6c288bf0fb0a6fbb273abf6 100644 (file)
@@ -6168,10 +6168,8 @@ intel_dp_init(struct drm_device *dev, int output_reg, enum port port)
                return;
 
        intel_connector = intel_connector_alloc();
-       if (!intel_connector) {
-               kfree(intel_dig_port);
-               return;
-       }
+       if (!intel_connector)
+               goto err_connector_alloc;
 
        intel_encoder = &intel_dig_port->base;
        encoder = &intel_encoder->base;
@@ -6219,11 +6217,18 @@ intel_dp_init(struct drm_device *dev, int output_reg, enum port port)
        intel_dig_port->hpd_pulse = intel_dp_hpd_pulse;
        dev_priv->hotplug.irq_port[port] = intel_dig_port;
 
-       if (!intel_dp_init_connector(intel_dig_port, intel_connector)) {
-               drm_encoder_cleanup(encoder);
-               kfree(intel_dig_port);
-               kfree(intel_connector);
-       }
+       if (!intel_dp_init_connector(intel_dig_port, intel_connector))
+               goto err_init_connector;
+
+       return;
+
+err_init_connector:
+       drm_encoder_cleanup(encoder);
+       kfree(intel_connector);
+err_connector_alloc:
+       kfree(intel_dig_port);
+
+       return;
 }
 
 void intel_dp_mst_suspend(struct drm_device *dev)