diff options
author | Jeremy Kerr <jk@ozlabs.org> | 2013-12-02 11:20:04 +0800 |
---|---|---|
committer | Jeremy Kerr <jk@ozlabs.org> | 2013-12-02 12:05:13 +0800 |
commit | d27570168fd6d5a2144553002c8082ae626b7e84 (patch) | |
tree | 4919cc264ea7f51aa6f8add8b404faeac50a65f9 /discover/device-handler.c | |
parent | c4f34e487fbf061ee6385d1f75e4ef0084c9a1ba (diff) | |
download | talos-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.c | 11 |
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])); |