[Mesa-dev] [PATCH] gallium/radeon: don't crash when getting out-of-bounds TEMP references

Tom Stellard tom at stellard.net
Thu Apr 23 07:03:58 PDT 2015


On Sat, Apr 11, 2015 at 09:11:13PM +0200, Marek Olšák wrote:
> From: Marek Olšák <marek.olsak at amd.com>
Reviewed-by: Tom Stellard <thomas.stellard at amd.com>
> 
> ---
>  src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
> index 1690194..333f7ae 100644
> --- a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
> +++ b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
> @@ -191,6 +191,8 @@ emit_fetch(
>  		break;
>  
>  	case TGSI_FILE_TEMPORARY:
> +		if (reg->Register.Index >= ctx->temps_count)
> +			return LLVMGetUndef(tgsi2llvmtype(bld_base, type));
>  		if (uses_temp_indirect_addressing(bld_base)) {
>  			ptr = lp_get_temp_ptr_soa(bld, reg->Register.Index, swizzle);
>  			break;
> @@ -395,6 +397,8 @@ emit_store(
>  					break;
>  
>  				case TGSI_FILE_TEMPORARY:
> +					if (range.First + i >= ctx->temps_count)
> +						continue;
>  					if (uses_temp_indirect_addressing(bld_base))
>  						temp_ptr = lp_get_temp_ptr_soa(bld, i + range.First, chan_index);
>  					else
> @@ -416,6 +420,8 @@ emit_store(
>  				break;
>  
>  			case TGSI_FILE_TEMPORARY:
> +				if (reg->Register.Index >= ctx->temps_count)
> +					continue;
>  				if (uses_temp_indirect_addressing(bld_base)) {
>  					temp_ptr = NULL;
>  					break;
> -- 
> 2.1.0
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list