summaryrefslogtreecommitdiff
path: root/usr/src/cmd/fwflash/common/fwflash.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/cmd/fwflash/common/fwflash.c')
-rw-r--r--usr/src/cmd/fwflash/common/fwflash.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/usr/src/cmd/fwflash/common/fwflash.c b/usr/src/cmd/fwflash/common/fwflash.c
index 59c3588f24..b08cac921d 100644
--- a/usr/src/cmd/fwflash/common/fwflash.c
+++ b/usr/src/cmd/fwflash/common/fwflash.c
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2020 Oxide Computer Company
*/
/*
@@ -440,8 +441,7 @@ flash_load_plugins()
continue;
}
- if ((sym = dlsym(tmpplug->handle, "plugin_version"))
- != NULL) {
+ if ((sym = dlsym(tmpplug->handle, "plugin_version")) != NULL) {
if ((*(int *)sym) >= FWPLUGIN_VERSION_2) {
if ((sym = dlsym(tmpplug->handle,
"fw_cleanup")) != NULL) {
@@ -1095,8 +1095,8 @@ static void
fwflash_intr(int sig)
{
- struct devicelist *thisdev;
- struct pluginlist *thisplug;
+ struct devicelist *thisdev, *tmpdev;
+ struct pluginlist *thisplug, *tmpplug;
(void) signal(SIGINT, SIG_IGN);
(void) signal(SIGTERM, SIG_IGN);
@@ -1120,7 +1120,8 @@ fwflash_intr(int sig)
* call the plugin closure routines
*/
if (fw_devices != NULL) {
- TAILQ_FOREACH(thisdev, fw_devices, nextdev) {
+ TAILQ_FOREACH_SAFE(thisdev, fw_devices, nextdev, tmpdev) {
+ TAILQ_REMOVE(fw_devices, thisdev, nextdev);
if (thisdev->plugin->fw_cleanup != NULL) {
/*
* If we've got a cleanup routine, it
@@ -1137,14 +1138,15 @@ fwflash_intr(int sig)
/* We don't free address[] for old plugins */
thisdev->ident = NULL;
thisdev->plugin = NULL;
+ free(thisdev);
}
- /* CONSTCOND */
- TAILQ_REMOVE(fw_devices, thisdev, nextdev);
}
}
if (fw_pluginlist != NULL) {
- TAILQ_FOREACH(thisplug, fw_pluginlist, nextplugin) {
+ TAILQ_FOREACH_SAFE(thisplug, fw_pluginlist, nextplugin,
+ tmpplug) {
+ TAILQ_REMOVE(fw_pluginlist, thisplug, nextplugin);
free(thisplug->filename);
free(thisplug->drvname);
free(thisplug->plugin->filename);
@@ -1162,8 +1164,7 @@ fwflash_intr(int sig)
thisplug->plugin->handle = NULL;
free(thisplug->plugin);
thisplug->plugin = NULL;
- /* CONSTCOND */
- TAILQ_REMOVE(fw_pluginlist, thisplug, nextplugin);
+ free(thisplug);
}
}