mirror of https://github.com/ipxe/ipxe.git
[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.pull/1/head
parent
4847d97372
commit
14c080020f
|
@ -156,7 +156,7 @@ void unregister_image ( struct image *image ) {
|
||||||
struct image * find_image ( const char *name ) {
|
struct image * find_image ( const char *name ) {
|
||||||
struct image *image;
|
struct image *image;
|
||||||
|
|
||||||
list_for_each_entry ( image, &images, list ) {
|
for_each_image ( image ) {
|
||||||
if ( strcmp ( image->name, name ) == 0 )
|
if ( strcmp ( image->name, name ) == 0 )
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
@ -172,12 +172,21 @@ struct image * find_image ( const char *name ) {
|
||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
static int image_load_type ( struct image *image, struct image_type *type ) {
|
static int image_load_type ( struct image *image, struct image_type *type ) {
|
||||||
|
struct image *tmp_image;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* Check image is actually loadable */
|
/* Check image is actually loadable */
|
||||||
if ( ! type->load )
|
if ( ! type->load )
|
||||||
return -ENOEXEC;
|
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 */
|
/* Try the image loader */
|
||||||
if ( ( rc = type->load ( image ) ) != 0 ) {
|
if ( ( rc = type->load ( image ) ) != 0 ) {
|
||||||
DBGC ( image, "IMAGE %p could not load as %s: %s\n",
|
DBGC ( image, "IMAGE %p could not load as %s: %s\n",
|
||||||
|
|
Loading…
Reference in New Issue