Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1242418

Re: [PATCH RESEND 1/3] drm/i915: use error path

From Daniel Vetter <daniel@ffwll.ch>
Newsgroups linux.kernel
Subject Re: [PATCH RESEND 1/3] drm/i915: use error path
Date 2015-10-08 16:30 +0200
Message-ID <qhkmK-67a-33@gated-at.bofh.it> (permalink)
References <qhjTI-5jJ-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Thu, Oct 08, 2015 at 07:27:59PM +0530, Sudip Mukherjee wrote:
> 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>

Queued for -next, thanks for the patch.
-Daniel

> ---
> 
> Sent on 27/07/2015
> 
>  drivers/gpu/drm/i915/intel_dp.c | 23 ++++++++++++++---------
>  1 file changed, 14 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> index 8d34ca7..18bcfbe 100644
> --- a/drivers/gpu/drm/i915/intel_dp.c
> +++ b/drivers/gpu/drm/i915/intel_dp.c
> @@ -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)
> -- 
> 1.9.1
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

[PATCH RESEND 1/3] drm/i915: use error path Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2015-10-08 16:00 +0200
  Re: [PATCH RESEND 1/3] drm/i915: use error path Daniel Vetter <daniel@ffwll.ch> - 2015-10-08 16:30 +0200

csiph-web