Skip to content

Commit

Permalink
delete watchdog timer when deinit is called
Browse files Browse the repository at this point in the history
to avoid system resource/memory leaked when guest os reboot.

Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
  • Loading branch information
mgcao authored and jren1 committed May 15, 2018
1 parent 6b4ad0b commit fdfb71e
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions devicemodel/hw/pci/wdt_i6300esb.c
Expand Up @@ -132,7 +132,7 @@ wdt_expired_thread(union sigval v)
}

static void
stop_wdt_timer()
stop_wdt_timer(void)
{
struct itimerspec timer_val;

Expand All @@ -145,6 +145,19 @@ stop_wdt_timer()
timer_settime(wdt_state.wdt_timerid, 0, &timer_val, NULL);
}

static void
delete_wdt_timer(void)
{
if (!wdt_state.timer_created)
return;

DPRINTF("%s: timer %ld deleted\n", __func__,
(uint64_t)wdt_state.wdt_timerid);

timer_delete(wdt_state.wdt_timerid);
wdt_state.timer_created = false;
}

static void
reset_wdt_timer(int seconds)
{
Expand Down Expand Up @@ -340,11 +353,10 @@ pci_wdt_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
return 0;
}


static void
pci_wdt_deinit(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
{
stop_wdt_timer();
delete_wdt_timer();
memset(&wdt_state, 0, sizeof(wdt_state));
}

Expand Down

0 comments on commit fdfb71e

Please sign in to comment.