summaryrefslogtreecommitdiffstats
path: root/discover/device-handler.c
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2013-12-02 11:20:04 +0800
committerJeremy Kerr <jk@ozlabs.org>2013-12-02 12:05:13 +0800
commitd27570168fd6d5a2144553002c8082ae626b7e84 (patch)
tree4919cc264ea7f51aa6f8add8b404faeac50a65f9 /discover/device-handler.c
parentc4f34e487fbf061ee6385d1f75e4ef0084c9a1ba (diff)
downloadtalos-petitboot-d27570168fd6d5a2144553002c8082ae626b7e84.tar.gz
talos-petitboot-d27570168fd6d5a2144553002c8082ae626b7e84.zip
discover/device-handler: Ensure we free unresolved boot options on remove
When we remove a device, some options may still be unresolved, and so won't be deallocated through freeing the device. This chagne explicitly removes & frees any currently-unresolved options for this device. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'discover/device-handler.c')
-rw-r--r--discover/device-handler.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/discover/device-handler.c b/discover/device-handler.c
index 9033c4f..d3256fa 100644
--- a/discover/device-handler.c
+++ b/discover/device-handler.c
@@ -279,6 +279,7 @@ struct device_handler *device_handler_init(struct discover_server *server,
void device_handler_remove(struct device_handler *handler,
struct discover_device *device)
{
+ struct discover_boot_option *opt, *tmp;
unsigned int i;
for (i = 0; i < handler->n_devices; i++)
@@ -290,6 +291,16 @@ void device_handler_remove(struct device_handler *handler,
return;
}
+ /* Free any unresolved options, as they're currently allocated
+ * against the handler */
+ list_for_each_entry_safe(&handler->unresolved_boot_options,
+ opt, tmp, list) {
+ if (opt->device != device)
+ continue;
+ list_remove(&opt->list);
+ talloc_free(opt);
+ }
+
handler->n_devices--;
memmove(&handler->devices[i], &handler->devices[i + 1],
(handler->n_devices - i) * sizeof(handler->devices[0]));
OpenPOWER on IntegriCloud