[Mesa-dev] [PATCH] vdpau: unlock the mutex on error paths in attribute setting.

Christian König deathsimple at vodafone.de
Tue Sep 2 00:51:02 PDT 2014


Am 02.09.2014 um 01:00 schrieb Dave Airlie:
> From: Dave Airlie <airlied at redhat.com>
>
> Coverity pointed out we never dropped the lock here, so fix
> it by using a common exit path.
>
> Signed-off-by: Dave Airlie <airlied at redhat.com>

Reviewed-by: Christian König <christian.koenig at amd.com>

> ---
>   src/gallium/state_trackers/vdpau/mixer.c | 38 ++++++++++++++++++++++----------
>   1 file changed, 26 insertions(+), 12 deletions(-)
>
> diff --git a/src/gallium/state_trackers/vdpau/mixer.c b/src/gallium/state_trackers/vdpau/mixer.c
> index a724aa5..4118eb8 100644
> --- a/src/gallium/state_trackers/vdpau/mixer.c
> +++ b/src/gallium/state_trackers/vdpau/mixer.c
> @@ -643,6 +643,7 @@ vlVdpVideoMixerSetAttributeValues(VdpVideoMixer mixer,
>      const float *vdp_csc;
>      float val;
>      unsigned i;
> +   VdpStatus ret;
>   
>      if (!(attributes && attribute_values))
>         return VDP_STATUS_INVALID_POINTER;
> @@ -676,8 +677,10 @@ vlVdpVideoMixerSetAttributeValues(VdpVideoMixer mixer,
>         case VDP_VIDEO_MIXER_ATTRIBUTE_NOISE_REDUCTION_LEVEL:
>   
>            val = *(float*)attribute_values[i];
> -         if (val < 0.f || val > 1.f)
> -            return VDP_STATUS_INVALID_VALUE;
> +         if (val < 0.f || val > 1.f) {
> +            ret = VDP_STATUS_INVALID_VALUE;
> +            goto fail;
> +         }
>   
>            vmixer->noise_reduction.level = val * 10;
>            vlVdpVideoMixerUpdateNoiseReductionFilter(vmixer);
> @@ -685,41 +688,52 @@ vlVdpVideoMixerSetAttributeValues(VdpVideoMixer mixer,
>   
>         case VDP_VIDEO_MIXER_ATTRIBUTE_LUMA_KEY_MIN_LUMA:
>            val = *(float*)attribute_values[i];
> -         if (val < 0.f || val > 1.f)
> -            return VDP_STATUS_INVALID_VALUE;
> +         if (val < 0.f || val > 1.f) {
> +            ret = VDP_STATUS_INVALID_VALUE;
> +            goto fail;
> +         }
>            vmixer->luma_key_min = val;
>            break;
>         case VDP_VIDEO_MIXER_ATTRIBUTE_LUMA_KEY_MAX_LUMA:
>            val = *(float*)attribute_values[i];
> -         if (val < 0.f || val > 1.f)
> -            return VDP_STATUS_INVALID_VALUE;
> +         if (val < 0.f || val > 1.f) {
> +            ret = VDP_STATUS_INVALID_VALUE;
> +            goto fail;
> +         }
>            vmixer->luma_key_max = val;
>            break;
>   
>         case VDP_VIDEO_MIXER_ATTRIBUTE_SHARPNESS_LEVEL:
>   
>            val = *(float*)attribute_values[i];
> -         if (val < -1.f || val > 1.f)
> -            return VDP_STATUS_INVALID_VALUE;
> +         if (val < -1.f || val > 1.f) {
> +            ret = VDP_STATUS_INVALID_VALUE;
> +            goto fail;
> +         }
>   
>            vmixer->sharpness.value = val;
>            vlVdpVideoMixerUpdateSharpnessFilter(vmixer);
>            break;
>   
>         case VDP_VIDEO_MIXER_ATTRIBUTE_SKIP_CHROMA_DEINTERLACE:
> -         if (*(uint8_t*)attribute_values[i] > 1)
> -            return VDP_STATUS_INVALID_VALUE;
> +         if (*(uint8_t*)attribute_values[i] > 1) {
> +            ret = VDP_STATUS_INVALID_VALUE;
> +            goto fail;
> +         }
>            vmixer->skip_chroma_deint = *(uint8_t*)attribute_values[i];
>            vlVdpVideoMixerUpdateDeinterlaceFilter(vmixer);
>            break;
>         default:
> -         pipe_mutex_unlock(vmixer->device->mutex);
> -         return VDP_STATUS_INVALID_VIDEO_MIXER_ATTRIBUTE;
> +         ret = VDP_STATUS_INVALID_VIDEO_MIXER_ATTRIBUTE;
> +         goto fail;
>         }
>      }
>      pipe_mutex_unlock(vmixer->device->mutex);
>   
>      return VDP_STATUS_OK;
> +fail:
> +   pipe_mutex_unlock(vmixer->device->mutex);
> +   return ret;
>   }
>   
>   /**



More information about the mesa-dev mailing list