libpayload: free: Separate NULL check out for clarity
Separate the validity check of calling free(NULL) for clarity. BUG=b:168441735 TEST=emerge-puff libpayload Change-Id: I0dc355553410bbe59e658945fb40c05f5f709380 Signed-off-by: Hsuan Ting Chen <roccochen@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/45465 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-by: Hung-Te Lin <hungte@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@google.com>
This commit is contained in:
		
				
					committed by
					
						 Hung-Te Lin
						Hung-Te Lin
					
				
			
			
				
	
			
			
			
						parent
						
							cbd0bd8155
						
					
				
				
					commit
					8742e2a923
				
			| @@ -246,6 +246,10 @@ void free(void *ptr) | |||||||
| 	hdrtype_t hdr; | 	hdrtype_t hdr; | ||||||
| 	struct memory_type *type = heap; | 	struct memory_type *type = heap; | ||||||
|  |  | ||||||
|  | 	/* No action occurs on NULL. */ | ||||||
|  | 	if (ptr == NULL) | ||||||
|  | 		return; | ||||||
|  |  | ||||||
| 	/* Sanity check. */ | 	/* Sanity check. */ | ||||||
| 	if (ptr < type->start || ptr >= type->end) { | 	if (ptr < type->start || ptr >= type->end) { | ||||||
| 		type = dma; | 		type = dma; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user