summaryrefslogtreecommitdiffstats
path: root/src/core/image.c
diff options
context:
space:
mode:
authorMichael Brown2008-07-08 04:03:48 +0200
committerMichael Brown2008-07-08 04:03:48 +0200
commit14c080020fb37cb34fe74213393f47bd2ad8b9bc (patch)
treeef8aef79cc1a4643e948f8f4b3998df6c7d12555 /src/core/image.c
parent[settings] Allow "config" command to access root settings block (diff)
downloadipxe-14c080020fb37cb34fe74213393f47bd2ad8b9bc.tar.gz
ipxe-14c080020fb37cb34fe74213393f47bd2ad8b9bc.tar.xz
ipxe-14c080020fb37cb34fe74213393f47bd2ad8b9bc.zip
[image] Clear LOADED flag on all other images when loading a new image
Loading an image may overwrite part or all of any previously-loaded images, so we should clear the LOADED flag for all images prior to attempting to load a new image.
Diffstat (limited to 'src/core/image.c')
-rw-r--r--src/core/image.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/core/image.c b/src/core/image.c
index 440a68c9..d896be0e 100644
--- a/src/core/image.c
+++ b/src/core/image.c
@@ -156,7 +156,7 @@ void unregister_image ( struct image *image ) {
struct image * find_image ( const char *name ) {
struct image *image;
- list_for_each_entry ( image, &images, list ) {
+ for_each_image ( image ) {
if ( strcmp ( image->name, name ) == 0 )
return image;
}
@@ -172,12 +172,21 @@ struct image * find_image ( const char *name ) {
* @ret rc Return status code
*/
static int image_load_type ( struct image *image, struct image_type *type ) {
+ struct image *tmp_image;
int rc;
/* Check image is actually loadable */
if ( ! type->load )
return -ENOEXEC;
+ /* Clear the loaded flag on all images; loading this image
+ * will invalidate any previous loads. (Even if loading
+ * fails, the previously loaded image may still have been
+ * partially overwritten.)
+ */
+ for_each_image ( tmp_image )
+ tmp_image->flags &= ~IMAGE_LOADED;
+
/* Try the image loader */
if ( ( rc = type->load ( image ) ) != 0 ) {
DBGC ( image, "IMAGE %p could not load as %s: %s\n",