Skip to content

Commit 5b14df3

Browse files
lyan3NanlinXie
authored andcommitted
hv: irq: fix type for vector in ioapic setup
Fix the type for vector in ioapic setup, which is a potential problem: - return VECTOR_INVALID instead of false in irq_desc_alloc_vector() when irq is out of range; - change variable type from int to uint32_t for vector, and correct the returned value check. Signed-off-by: Yan, Like <like.yan@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent bab8fad commit 5b14df3

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

hypervisor/arch/x86/ioapic.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ void setup_ioapic_irq(void)
304304
{
305305
int ioapic_id;
306306
uint32_t gsi;
307-
int vr;
307+
uint32_t vr;
308308

309309
spinlock_init(&ioapic_lock);
310310

@@ -343,7 +343,7 @@ void setup_ioapic_irq(void)
343343
*/
344344
if (gsi < NR_LEGACY_IRQ) {
345345
vr = irq_desc_alloc_vector(gsi, false);
346-
if (vr < 0) {
346+
if (vr > NR_MAX_VECTOR) {
347347
pr_err("failed to alloc VR");
348348
gsi++;
349349
continue;

hypervisor/arch/x86/irq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ uint32_t irq_desc_alloc_vector(uint32_t irq, bool lowpri)
327327

328328
/* irq should be always available at this time */
329329
if (irq > NR_MAX_IRQS)
330-
return false;
330+
return VECTOR_INVALID;
331331

332332
desc = irq_desc_base + irq;
333333
spinlock_irqsave_obtain(&desc->irq_lock);

0 commit comments

Comments
 (0)