Include a min() against the appropriate ARRAY_SIZE(), and ASSERT() that
max_subleaf is within ARRAY_SIZE().
This is more robust to unexpected problems in a release build of Xen.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Doug Goldstein <cardoe@cardoe.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
switch ( leaf )
{
case 0x7:
- if ( subleaf > p->feat.max_subleaf )
+ ASSERT(p->feat.max_subleaf < ARRAY_SIZE(p->feat.raw));
+ if ( subleaf > min_t(uint32_t, p->feat.max_subleaf,
+ ARRAY_SIZE(p->feat.raw) - 1) )
return;
- BUG_ON(subleaf >= ARRAY_SIZE(p->feat.raw));
*res = p->feat.raw[subleaf];
break;