diff mbox

[3/8] drm/i915/sdvo: Check error return from intel_sdvo_get_value()

Message ID 1493214013-15580-4-git-send-email-imre.deak@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Imre Deak April 26, 2017, 1:40 p.m. UTC
The current code assumes that 'enhancements' won't change in case of an
error, but this isn't guaranteed. Fix things by treating any error as a
lack of the given capability.

Signed-off-by: Imre Deak <imre.deak@intel.com>
---
 drivers/gpu/drm/i915/intel_sdvo.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Ville Syrjala April 26, 2017, 3:12 p.m. UTC | #1
On Wed, Apr 26, 2017 at 04:40:08PM +0300, Imre Deak wrote:
> The current code assumes that 'enhancements' won't change in case of an
> error, but this isn't guaranteed. Fix things by treating any error as a
> lack of the given capability.
> 
> Signed-off-by: Imre Deak <imre.deak@intel.com>
> ---
>  drivers/gpu/drm/i915/intel_sdvo.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
> index 816a6f5..0d1c511 100644
> --- a/drivers/gpu/drm/i915/intel_sdvo.c
> +++ b/drivers/gpu/drm/i915/intel_sdvo.c
> @@ -2893,10 +2893,10 @@ static bool intel_sdvo_create_enhance_property(struct intel_sdvo *intel_sdvo,
>  	BUILD_BUG_ON(sizeof(enhancements) != 2);
>  
>  	enhancements.response = 0;

This initialization could be removed if we don't use the thing
when the read fails.

Either way
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

> -	intel_sdvo_get_value(intel_sdvo,
> -			     SDVO_CMD_GET_SUPPORTED_ENHANCEMENTS,
> -			     &enhancements, sizeof(enhancements));
> -	if (enhancements.response == 0) {
> +	if (!intel_sdvo_get_value(intel_sdvo,
> +				  SDVO_CMD_GET_SUPPORTED_ENHANCEMENTS,
> +				  &enhancements, sizeof(enhancements)) ||
> +	    enhancements.response == 0) {
>  		DRM_DEBUG_KMS("No enhancement is supported\n");
>  		return true;
>  	}
> -- 
> 2.5.0
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Imre Deak April 26, 2017, 3:24 p.m. UTC | #2
On Wed, Apr 26, 2017 at 06:12:09PM +0300, Ville Syrjälä wrote:
> On Wed, Apr 26, 2017 at 04:40:08PM +0300, Imre Deak wrote:
> > The current code assumes that 'enhancements' won't change in case of an
> > error, but this isn't guaranteed. Fix things by treating any error as a
> > lack of the given capability.
> > 
> > Signed-off-by: Imre Deak <imre.deak@intel.com>
> > ---
> >  drivers/gpu/drm/i915/intel_sdvo.c | 8 ++++----
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
> > index 816a6f5..0d1c511 100644
> > --- a/drivers/gpu/drm/i915/intel_sdvo.c
> > +++ b/drivers/gpu/drm/i915/intel_sdvo.c
> > @@ -2893,10 +2893,10 @@ static bool intel_sdvo_create_enhance_property(struct intel_sdvo *intel_sdvo,
> >  	BUILD_BUG_ON(sizeof(enhancements) != 2);
> >  
> >  	enhancements.response = 0;
> 
> This initialization could be removed if we don't use the thing
> when the read fails.

Yep, missed this, will remove it.

> 
> Either way
> Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> > -	intel_sdvo_get_value(intel_sdvo,
> > -			     SDVO_CMD_GET_SUPPORTED_ENHANCEMENTS,
> > -			     &enhancements, sizeof(enhancements));
> > -	if (enhancements.response == 0) {
> > +	if (!intel_sdvo_get_value(intel_sdvo,
> > +				  SDVO_CMD_GET_SUPPORTED_ENHANCEMENTS,
> > +				  &enhancements, sizeof(enhancements)) ||
> > +	    enhancements.response == 0) {
> >  		DRM_DEBUG_KMS("No enhancement is supported\n");
> >  		return true;
> >  	}
> > -- 
> > 2.5.0
> > 
> > _______________________________________________
> > Intel-gfx mailing list
> > Intel-gfx@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/intel-gfx
> 
> -- 
> Ville Syrjälä
> Intel OTC
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
index 816a6f5..0d1c511 100644
--- a/drivers/gpu/drm/i915/intel_sdvo.c
+++ b/drivers/gpu/drm/i915/intel_sdvo.c
@@ -2893,10 +2893,10 @@  static bool intel_sdvo_create_enhance_property(struct intel_sdvo *intel_sdvo,
 	BUILD_BUG_ON(sizeof(enhancements) != 2);
 
 	enhancements.response = 0;
-	intel_sdvo_get_value(intel_sdvo,
-			     SDVO_CMD_GET_SUPPORTED_ENHANCEMENTS,
-			     &enhancements, sizeof(enhancements));
-	if (enhancements.response == 0) {
+	if (!intel_sdvo_get_value(intel_sdvo,
+				  SDVO_CMD_GET_SUPPORTED_ENHANCEMENTS,
+				  &enhancements, sizeof(enhancements)) ||
+	    enhancements.response == 0) {
 		DRM_DEBUG_KMS("No enhancement is supported\n");
 		return true;
 	}