2019-10-08 20:48:51

by Yizhuo Zhai

[permalink] [raw]
Subject: [PATCH] x86/hpet: Fix uninitialized use in hpet_msi_resume()

Inside function hpet_msi_resume(), variable "msg" could be
uninitialized if irq_chip_compose_msi_msg() returns -ENOSYS.
However, it is directly used in hpet_msi_write(), which is
potentially unsafe.

Signed-off-by: Yizhuo <[email protected]>
---
arch/x86/kernel/hpet.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c
index c6f791bc481e..5bc76819dd32 100644
--- a/arch/x86/kernel/hpet.c
+++ b/arch/x86/kernel/hpet.c
@@ -501,6 +501,7 @@ static int hpet_clkevt_msi_resume(struct clock_event_device *evt)
struct irq_data *data = irq_get_irq_data(hc->irq);
struct msi_msg msg;

+ memset(&msg, 0, sizeof(struct msi_msg));
/* Restore the MSI msg and unmask the interrupt */
irq_chip_compose_msi_msg(data, &msg);
hpet_msi_write(hc, &msg);
--
2.17.1