tools/intel_reg: Fix segfault in intel_reg dump

Submitted by Mika Kuoppala on Feb. 2, 2018, 1:19 p.m.

Details

Message ID 20180202131950.24210-1-mika.kuoppala@linux.intel.com
State New
Headers show
Series "tools/intel_reg: Fix segfault in intel_reg dump" ( rev: 2 ) in IGT (deprecated)

Not browsing as part of any series.

Commit Message

Mika Kuoppala Feb. 2, 2018, 1:19 p.m.
We need to zero out the builtin reg spec we are parsing into.
Otherwise engine will be uninitialized and we segfault when trying
to find engine and accessing reg->engine in later stage.

v2: use {} (Jani)

Fixes: 7f0be0e7d9be ("tools/intel_reg: Add reading and writing registers through engine")
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104895
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Marta Löfstedt <marta.lofstedt@intel.com>
Cc: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
---
 tools/intel_reg_decode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/tools/intel_reg_decode.c b/tools/intel_reg_decode.c
index 46b19676..f3c7d74a 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);

Comments

Mika Kuoppala <mika.kuoppala@linux.intel.com> writes:

> We need to zero out the builtin reg spec we are parsing into.
> Otherwise engine will be uninitialized and we segfault when trying
> to find engine and accessing reg->engine in later stage.
>

Chris combined both file and builting based fixes. We can omit this.
-Mika


> v2: use {} (Jani)
>
> Fixes: 7f0be0e7d9be ("tools/intel_reg: Add reading and writing registers through engine")
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104895
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Marta Löfstedt <marta.lofstedt@intel.com>
> Cc: Jani Nikula <jani.nikula@intel.com>
> Signed-off-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
> Reviewed-by: Jani Nikula <jani.nikula@intel.com>
> ---
>  tools/intel_reg_decode.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/intel_reg_decode.c b/tools/intel_reg_decode.c
> index 46b19676..f3c7d74a 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);
> -- 
> 2.14.1