mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	bzip2/lzma/gzip: pre-boot malloc doesn't return NULL on failure
The trivial malloc implementation used in the pre-boot environment by the decompressors returns a bad pointer on failure (falling through after calling error). This is doubly wrong - the callers expect malloc to return NULL on failure, second the error function is intended to be used by the decompressors to propagate errors to *their* callers. The decompressors have no access to any state set by the error function. Signed-off-by: Phillip Lougher <phillip@lougher.demon.co.uk> LKML-Reference: <4b26b1ef.hIInb2AYPMtImAJO%phillip@lougher.demon.co.uk> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
This commit is contained in:
		
							parent
							
								
									23637568ad
								
							
						
					
					
						commit
						c1e7c3ae59
					
				
					 1 changed files with 2 additions and 2 deletions
				
			
		| 
						 | 
					@ -25,7 +25,7 @@ static void *malloc(int size)
 | 
				
			||||||
	void *p;
 | 
						void *p;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (size < 0)
 | 
						if (size < 0)
 | 
				
			||||||
		error("Malloc error");
 | 
							return NULL;
 | 
				
			||||||
	if (!malloc_ptr)
 | 
						if (!malloc_ptr)
 | 
				
			||||||
		malloc_ptr = free_mem_ptr;
 | 
							malloc_ptr = free_mem_ptr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -35,7 +35,7 @@ static void *malloc(int size)
 | 
				
			||||||
	malloc_ptr += size;
 | 
						malloc_ptr += size;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (free_mem_end_ptr && malloc_ptr >= free_mem_end_ptr)
 | 
						if (free_mem_end_ptr && malloc_ptr >= free_mem_end_ptr)
 | 
				
			||||||
		error("Out of memory");
 | 
							return NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	malloc_count++;
 | 
						malloc_count++;
 | 
				
			||||||
	return p;
 | 
						return p;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue