From: Richard Henderson Date: Fri, 29 Jun 2018 23:30:28 +0000 (-0700) Subject: cpu: Assert asidx_from_attrs return value in range X-Git-Tag: qemu-xen-4.12.0-rc1~113^2 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=9c8c334b0637bf3c592d432b0c11f3b62dd5dba3;p=qemu-xen.git cpu: Assert asidx_from_attrs return value in range Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- diff --git a/include/qom/cpu.h b/include/qom/cpu.h index cce2fd6acc..bd796579ee 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -620,11 +620,13 @@ static inline hwaddr cpu_get_phys_page_debug(CPUState *cpu, vaddr addr) static inline int cpu_asidx_from_attrs(CPUState *cpu, MemTxAttrs attrs) { CPUClass *cc = CPU_GET_CLASS(cpu); + int ret = 0; if (cc->asidx_from_attrs) { - return cc->asidx_from_attrs(cpu, attrs); + ret = cc->asidx_from_attrs(cpu, attrs); + assert(ret < cpu->num_ases && ret >= 0); } - return 0; + return ret; } #endif