[igt-dev] [PATCH igt v2] tools: Clear unused fields in register spec

Mika Kuoppala mika.kuoppala at linux.intel.com
Fri Feb 2 13:21:50 UTC 2018


Chris Wilson <chris at chris-wilson.co.uk> writes:

> If we fail to clear the other fields inside the register spec, that may
> be left with garbage instructing us to access the register via an
> invalid path.
>
> v2: Grab Mika's fix for get_regs() and check all parse_port_desc()
> callers.

Ok. I omit mine.

>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104895
> Fixes: 7f0be0e7d9be ("tools/intel_reg: Add reading and writing registers through engine")
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> Cc: Jani Nikula <jani.nikula at intel.com>
> CC: Joonas Lahtinen <joonas.lahtinen at linux.intel.com>
> Cc: Mika Kuoppala <mika.kuoppala at linux.intel.com>
> Reviewed-by: Jani Nikula <jani.nikula at intel.com>

Reviewed-by: Mika Kuoppala <mika.kuoppala at linux.intel.com>

> ---
>  tools/intel_reg_decode.c | 2 +-
>  tools/intel_reg_spec.c   | 4 +---
>  2 files changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/tools/intel_reg_decode.c b/tools/intel_reg_decode.c
> index 46b196763..f3c7d74a3 100644
> --- a/tools/intel_reg_decode.c
> +++ b/tools/intel_reg_decode.c
> @@ -2746,7 +2746,7 @@ static ssize_t get_regs(struct reg **regs, size_t *nregs, ssize_t index,
>  		for (j = 0; j < known_registers[i].count; j++) {
>  			const struct reg_debug *reg_in =
>  				&known_registers[i].regs[j];
> -			struct reg reg;
> +			struct reg reg = {};
>  
>  			/* XXX: Could be optimized. */
>  			parse_port_desc(&reg, NULL);
> diff --git a/tools/intel_reg_spec.c b/tools/intel_reg_spec.c
> index 5594d7077..0df69b688 100644
> --- a/tools/intel_reg_spec.c
> +++ b/tools/intel_reg_spec.c
> @@ -219,8 +219,6 @@ static int parse_line(struct reg *reg, const char *line)
>  		initialized = true;
>  	}
>  
> -	memset(reg, 0, sizeof(*reg));
> -
>  	ret = regexec(&regex, line, ARRAY_SIZE(match), match, 0);
>  	if (ret)
>  		ret = -1;
> @@ -267,7 +265,7 @@ static ssize_t parse_file(struct reg **regs, size_t *nregs,
>  	}
>  
>  	while (getline(&line, &linesize, file) != -1) {
> -		struct reg reg;
> +		struct reg reg = {};
>  
>  		lineno++;
>  
> -- 
> 2.15.1


More information about the igt-dev mailing list