mirror of
				git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
				synced 2025-10-31 08:44:41 +00:00 
			
		
		
		
	hwmon (coretemp) Fix a memory leak bug
In coretemp_init(), 'zone_devices' is allocated through kcalloc(). However, it is not deallocated in the following execution if platform_driver_register() fails, leading to a memory leak. To fix this issue, introduce the 'outzone' label to free 'zone_devices' before returning the error. Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu> Link: https://lore.kernel.org/r/1566248402-6538-1-git-send-email-wenwen@cs.uga.edu Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
		
							parent
							
								
									7d82fcc9d9
								
							
						
					
					
						commit
						e027a2dea5
					
				
					 1 changed files with 2 additions and 1 deletions
				
			
		|  | @ -736,7 +736,7 @@ static int __init coretemp_init(void) | |||
| 
 | ||||
| 	err = platform_driver_register(&coretemp_driver); | ||||
| 	if (err) | ||||
| 		return err; | ||||
| 		goto outzone; | ||||
| 
 | ||||
| 	err = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "hwmon/coretemp:online", | ||||
| 				coretemp_cpu_online, coretemp_cpu_offline); | ||||
|  | @ -747,6 +747,7 @@ static int __init coretemp_init(void) | |||
| 
 | ||||
| outdrv: | ||||
| 	platform_driver_unregister(&coretemp_driver); | ||||
| outzone: | ||||
| 	kfree(zone_devices); | ||||
| 	return err; | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Wenwen Wang
						Wenwen Wang