forked from mirrors/linux
		
	spi: gpio: prevent memory leak in spi_gpio_probe
In spi_gpio_probe an SPI master is allocated via spi_alloc_master, but
this controller should be released if devm_add_action_or_reset fails,
otherwise memory leaks. In order to avoid leak spi_contriller_put must
be called in case of failure for devm_add_action_or_reset.
Fixes: 8b797490b4 ("spi: gpio: Make sure spi_master_put() is called in every error path")
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
Link: https://lore.kernel.org/r/20190930205241.5483-1-navid.emamdoost@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
			
			
This commit is contained in:
		
							parent
							
								
									6b04e47b73
								
							
						
					
					
						commit
						d3b0ffa1d7
					
				
					 1 changed files with 3 additions and 1 deletions
				
			
		|  | @ -371,8 +371,10 @@ static int spi_gpio_probe(struct platform_device *pdev) | ||||||
| 		return -ENOMEM; | 		return -ENOMEM; | ||||||
| 
 | 
 | ||||||
| 	status = devm_add_action_or_reset(&pdev->dev, spi_gpio_put, master); | 	status = devm_add_action_or_reset(&pdev->dev, spi_gpio_put, master); | ||||||
| 	if (status) | 	if (status) { | ||||||
|  | 		spi_master_put(master); | ||||||
| 		return status; | 		return status; | ||||||
|  | 	} | ||||||
| 
 | 
 | ||||||
| 	if (of_id) | 	if (of_id) | ||||||
| 		status = spi_gpio_probe_dt(pdev, master); | 		status = spi_gpio_probe_dt(pdev, master); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Navid Emamdoost
						Navid Emamdoost