hv: fix potential buffer overflow in vpic_set_pinstate()

Input 'pin' should be less than 'NR_VPIC_PINS_TOTAL'

Tracked-On: #1479
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Yonghua Huang 2018-10-19 16:31:46 +08:00 committed by Xie, Nanlin
parent 268a9f1453
commit bd042352cd

View File

@ -405,6 +405,10 @@ static void vpic_set_pinstate(struct acrn_vpic *vpic, uint8_t pin,
uint8_t old_lvl; uint8_t old_lvl;
bool lvl_trigger; bool lvl_trigger;
if (pin >= NR_VPIC_PINS_TOTAL) {
return;
}
i8259 = &vpic->i8259[pin >> 3U]; i8259 = &vpic->i8259[pin >> 3U];
old_lvl = i8259->pin_state[pin & 0x7U]; old_lvl = i8259->pin_state[pin & 0x7U];
if (level) { if (level) {