diff mbox

[i-g-t] tools/intel_reg: Fix segfault in intel_reg dump

Message ID 20180202103427.7655-1-mika.kuoppala@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Mika Kuoppala Feb. 2, 2018, 10:34 a.m. UTC
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.

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>
---
 tools/intel_reg_decode.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Jani Nikula Feb. 2, 2018, 11:07 a.m. UTC | #1
On Fri, 02 Feb 2018, Mika Kuoppala <mika.kuoppala@linux.intel.com> wrote:
> 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.
>
> 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>

Personal preference, I would've gone for = {} but this is fine.

Reviewed-by: Jani Nikula <jani.nikula@intel.com>

> ---
>  tools/intel_reg_decode.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/tools/intel_reg_decode.c b/tools/intel_reg_decode.c
> index 46b19676..b351dcb5 100644
> --- a/tools/intel_reg_decode.c
> +++ b/tools/intel_reg_decode.c
> @@ -2748,6 +2748,8 @@ static ssize_t get_regs(struct reg **regs, size_t *nregs, ssize_t index,
>  				&known_registers[i].regs[j];
>  			struct reg reg;
>  
> +			memset(&reg, 0, sizeof(reg));
> +
>  			/* XXX: Could be optimized. */
>  			parse_port_desc(&reg, NULL);
diff mbox

Patch

diff --git a/tools/intel_reg_decode.c b/tools/intel_reg_decode.c
index 46b19676..b351dcb5 100644
--- a/tools/intel_reg_decode.c
+++ b/tools/intel_reg_decode.c
@@ -2748,6 +2748,8 @@  static ssize_t get_regs(struct reg **regs, size_t *nregs, ssize_t index,
 				&known_registers[i].regs[j];
 			struct reg reg;
 
+			memset(&reg, 0, sizeof(reg));
+
 			/* XXX: Could be optimized. */
 			parse_port_desc(&reg, NULL);