[RESEND,2/3] drm/i915: check for return value
diff mbox

Message ID 1444312681-10149-2-git-send-email-sudipm.mukherjee@gmail.com
State New
Headers show

Commit Message

Sudip Mukherjee Oct. 8, 2015, 1:58 p.m. UTC
We were not checking the return value of drm_encoder_init() which can
fail. And if it fails then we will be working with an uninitialized
encoder.

Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---

Sent on 27/07/2015

 drivers/gpu/drm/i915/intel_dp.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Daniel Vetter Oct. 8, 2015, 2:29 p.m. UTC | #1
On Thu, Oct 08, 2015 at 07:28:00PM +0530, Sudip Mukherjee wrote:
> We were not checking the return value of drm_encoder_init() which can
> fail. And if it fails then we will be working with an uninitialized
> encoder.
> 
> 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 | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> index 18bcfbe..2a8b47e 100644
> --- a/drivers/gpu/drm/i915/intel_dp.c
> +++ b/drivers/gpu/drm/i915/intel_dp.c
> @@ -6174,8 +6174,9 @@ intel_dp_init(struct drm_device *dev, int output_reg, enum port port)
>  	intel_encoder = &intel_dig_port->base;
>  	encoder = &intel_encoder->base;
>  
> -	drm_encoder_init(dev, &intel_encoder->base, &intel_dp_enc_funcs,
> -			 DRM_MODE_ENCODER_TMDS);
> +	if (drm_encoder_init(dev, &intel_encoder->base, &intel_dp_enc_funcs,
> +			     DRM_MODE_ENCODER_TMDS))
> +		goto err_encoder_init;
>  
>  	intel_encoder->compute_config = intel_dp_compute_config;
>  	intel_encoder->disable = intel_disable_dp;
> @@ -6224,6 +6225,7 @@ intel_dp_init(struct drm_device *dev, int output_reg, enum port port)
>  
>  err_init_connector:
>  	drm_encoder_cleanup(encoder);
> +err_encoder_init:
>  	kfree(intel_connector);
>  err_connector_alloc:
>  	kfree(intel_dig_port);
> -- 
> 1.9.1
>
Sudip Mukherjee Dec. 9, 2015, 11:39 a.m. UTC | #2
On Thu, Oct 08, 2015 at 04:29:31PM +0200, Daniel Vetter wrote:
> On Thu, Oct 08, 2015 at 07:28:00PM +0530, Sudip Mukherjee wrote:
> > We were not checking the return value of drm_encoder_init() which can
> > fail. And if it fails then we will be working with an uninitialized
> > encoder.
> > 
> > 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

Hi Daniel,
It is still not there in linux-next. Still applies cleanly on
next-20151209.

regards
sudip

> 
> > ---
> > 
> > Sent on 27/07/2015
> > 
> >  drivers/gpu/drm/i915/intel_dp.c | 6 ++++--
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> > index 18bcfbe..2a8b47e 100644
> > --- a/drivers/gpu/drm/i915/intel_dp.c
> > +++ b/drivers/gpu/drm/i915/intel_dp.c
> > @@ -6174,8 +6174,9 @@ intel_dp_init(struct drm_device *dev, int output_reg, enum port port)
> >  	intel_encoder = &intel_dig_port->base;
> >  	encoder = &intel_encoder->base;
> >  
> > -	drm_encoder_init(dev, &intel_encoder->base, &intel_dp_enc_funcs,
> > -			 DRM_MODE_ENCODER_TMDS);
> > +	if (drm_encoder_init(dev, &intel_encoder->base, &intel_dp_enc_funcs,
> > +			     DRM_MODE_ENCODER_TMDS))
> > +		goto err_encoder_init;
> >  
> >  	intel_encoder->compute_config = intel_dp_compute_config;
> >  	intel_encoder->disable = intel_disable_dp;
> > @@ -6224,6 +6225,7 @@ intel_dp_init(struct drm_device *dev, int output_reg, enum port port)
> >  
> >  err_init_connector:
> >  	drm_encoder_cleanup(encoder);
> > +err_encoder_init:
> >  	kfree(intel_connector);
> >  err_connector_alloc:
> >  	kfree(intel_dig_port);
> > -- 
> > 1.9.1
> > 
> 
> -- 
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch
Daniel Vetter Dec. 9, 2015, 1:33 p.m. UTC | #3
On Wed, Dec 09, 2015 at 05:09:12PM +0530, Sudip Mukherjee wrote:
> On Thu, Oct 08, 2015 at 04:29:31PM +0200, Daniel Vetter wrote:
> > On Thu, Oct 08, 2015 at 07:28:00PM +0530, Sudip Mukherjee wrote:
> > > We were not checking the return value of drm_encoder_init() which can
> > > fail. And if it fails then we will be working with an uninitialized
> > > encoder.
> > > 
> > > 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
> 
> Hi Daniel,
> It is still not there in linux-next. Still applies cleanly on
> next-20151209.

Sorry, this must have fallen through the cracks somehow. Applied now for
real.

Thanks, Daniel

> 
> regards
> sudip
> 
> > 
> > > ---
> > > 
> > > Sent on 27/07/2015
> > > 
> > >  drivers/gpu/drm/i915/intel_dp.c | 6 ++++--
> > >  1 file changed, 4 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> > > index 18bcfbe..2a8b47e 100644
> > > --- a/drivers/gpu/drm/i915/intel_dp.c
> > > +++ b/drivers/gpu/drm/i915/intel_dp.c
> > > @@ -6174,8 +6174,9 @@ intel_dp_init(struct drm_device *dev, int output_reg, enum port port)
> > >  	intel_encoder = &intel_dig_port->base;
> > >  	encoder = &intel_encoder->base;
> > >  
> > > -	drm_encoder_init(dev, &intel_encoder->base, &intel_dp_enc_funcs,
> > > -			 DRM_MODE_ENCODER_TMDS);
> > > +	if (drm_encoder_init(dev, &intel_encoder->base, &intel_dp_enc_funcs,
> > > +			     DRM_MODE_ENCODER_TMDS))
> > > +		goto err_encoder_init;
> > >  
> > >  	intel_encoder->compute_config = intel_dp_compute_config;
> > >  	intel_encoder->disable = intel_disable_dp;
> > > @@ -6224,6 +6225,7 @@ intel_dp_init(struct drm_device *dev, int output_reg, enum port port)
> > >  
> > >  err_init_connector:
> > >  	drm_encoder_cleanup(encoder);
> > > +err_encoder_init:
> > >  	kfree(intel_connector);
> > >  err_connector_alloc:
> > >  	kfree(intel_dig_port);
> > > -- 
> > > 1.9.1
> > > 
> > 
> > -- 
> > Daniel Vetter
> > Software Engineer, Intel Corporation
> > http://blog.ffwll.ch
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

Patch
diff mbox

diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index 18bcfbe..2a8b47e 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -6174,8 +6174,9 @@  intel_dp_init(struct drm_device *dev, int output_reg, enum port port)
 	intel_encoder = &intel_dig_port->base;
 	encoder = &intel_encoder->base;
 
-	drm_encoder_init(dev, &intel_encoder->base, &intel_dp_enc_funcs,
-			 DRM_MODE_ENCODER_TMDS);
+	if (drm_encoder_init(dev, &intel_encoder->base, &intel_dp_enc_funcs,
+			     DRM_MODE_ENCODER_TMDS))
+		goto err_encoder_init;
 
 	intel_encoder->compute_config = intel_dp_compute_config;
 	intel_encoder->disable = intel_disable_dp;
@@ -6224,6 +6225,7 @@  intel_dp_init(struct drm_device *dev, int output_reg, enum port port)
 
 err_init_connector:
 	drm_encoder_cleanup(encoder);
+err_encoder_init:
 	kfree(intel_connector);
 err_connector_alloc:
 	kfree(intel_dig_port);