|  | @@ -156,7 +156,7 @@ void unregister_image ( struct image *image ) {
 | 
		
	
		
			
			| 156 | 156 |  struct image * find_image ( const char *name ) {
 | 
		
	
		
			
			| 157 | 157 |  	struct image *image;
 | 
		
	
		
			
			| 158 | 158 |  
 | 
		
	
		
			
			| 159 |  | -	list_for_each_entry ( image, &images, list ) {
 | 
		
	
		
			
			|  | 159 | +	for_each_image ( image ) {
 | 
		
	
		
			
			| 160 | 160 |  		if ( strcmp ( image->name, name ) == 0 )
 | 
		
	
		
			
			| 161 | 161 |  			return image;
 | 
		
	
		
			
			| 162 | 162 |  	}
 | 
		
	
	
		
			
			|  | @@ -172,12 +172,21 @@ struct image * find_image ( const char *name ) {
 | 
		
	
		
			
			| 172 | 172 |   * @ret rc		Return status code
 | 
		
	
		
			
			| 173 | 173 |   */
 | 
		
	
		
			
			| 174 | 174 |  static int image_load_type ( struct image *image, struct image_type *type ) {
 | 
		
	
		
			
			|  | 175 | +	struct image *tmp_image;
 | 
		
	
		
			
			| 175 | 176 |  	int rc;
 | 
		
	
		
			
			| 176 | 177 |  
 | 
		
	
		
			
			| 177 | 178 |  	/* Check image is actually loadable */
 | 
		
	
		
			
			| 178 | 179 |  	if ( ! type->load )
 | 
		
	
		
			
			| 179 | 180 |  		return -ENOEXEC;
 | 
		
	
		
			
			| 180 | 181 |  
 | 
		
	
		
			
			|  | 182 | +	/* Clear the loaded flag on all images; loading this image
 | 
		
	
		
			
			|  | 183 | +	 * will invalidate any previous loads.  (Even if loading
 | 
		
	
		
			
			|  | 184 | +	 * fails, the previously loaded image may still have been
 | 
		
	
		
			
			|  | 185 | +	 * partially overwritten.)
 | 
		
	
		
			
			|  | 186 | +	 */
 | 
		
	
		
			
			|  | 187 | +	for_each_image ( tmp_image )
 | 
		
	
		
			
			|  | 188 | +		tmp_image->flags &= ~IMAGE_LOADED;
 | 
		
	
		
			
			|  | 189 | +
 | 
		
	
		
			
			| 181 | 190 |  	/* Try the image loader */
 | 
		
	
		
			
			| 182 | 191 |  	if ( ( rc = type->load ( image ) ) != 0 ) {
 | 
		
	
		
			
			| 183 | 192 |  		DBGC ( image, "IMAGE %p could not load as %s: %s\n",
 |