Jelajahi Sumber

drm/i915: Fix memory leak in intel_dsi_init() error path

intel_dsi_init() bails out without freeing the memory 'intel_dsi' and
'intel_connector' point to. Simply bail out before allocating memory.

Picked up by Coverity - CID 1222750.

Signed-off-by: Christoph Jaeger <christophjaeger@linux.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Christoph Jaeger 11 tahun lalu
induk
melakukan
868d665b43
1 mengubah file dengan 7 tambahan dan 7 penghapusan
  1. 7 7
      drivers/gpu/drm/i915/intel_dsi.c

+ 7 - 7
drivers/gpu/drm/i915/intel_dsi.c

@@ -675,6 +675,13 @@ void intel_dsi_init(struct drm_device *dev)
 	if (!dev_priv->vbt.has_mipi)
 	if (!dev_priv->vbt.has_mipi)
 		return;
 		return;
 
 
+	if (IS_VALLEYVIEW(dev)) {
+		dev_priv->mipi_mmio_base = VLV_MIPI_BASE;
+	} else {
+		DRM_ERROR("Unsupported Mipi device to reg base");
+		return;
+	}
+
 	intel_dsi = kzalloc(sizeof(*intel_dsi), GFP_KERNEL);
 	intel_dsi = kzalloc(sizeof(*intel_dsi), GFP_KERNEL);
 	if (!intel_dsi)
 	if (!intel_dsi)
 		return;
 		return;
@@ -689,13 +696,6 @@ void intel_dsi_init(struct drm_device *dev)
 	encoder = &intel_encoder->base;
 	encoder = &intel_encoder->base;
 	intel_dsi->attached_connector = intel_connector;
 	intel_dsi->attached_connector = intel_connector;
 
 
-	if (IS_VALLEYVIEW(dev)) {
-		dev_priv->mipi_mmio_base = VLV_MIPI_BASE;
-	} else {
-		DRM_ERROR("Unsupported Mipi device to reg base");
-		return;
-	}
-
 	connector = &intel_connector->base;
 	connector = &intel_connector->base;
 
 
 	drm_encoder_init(dev, encoder, &intel_dsi_funcs, DRM_MODE_ENCODER_DSI);
 	drm_encoder_init(dev, encoder, &intel_dsi_funcs, DRM_MODE_ENCODER_DSI);