mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	PCI: Don't leak memory if sysfs_create_bin_file() fails
If sysfs_create_bin_file() fails, pci_create_attr() leaks the struct bin_attribute it allocated previously. Free the struct bin_attribute if pci_create_attr() fails. Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
This commit is contained in:
		
							parent
							
								
									9d88b93bea
								
							
						
					
					
						commit
						b562ec8f74
					
				
					 1 changed files with 2 additions and 0 deletions
				
			
		| 
						 | 
					@ -1159,6 +1159,8 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
 | 
				
			||||||
		res_attr->size = pci_resource_len(pdev, num);
 | 
							res_attr->size = pci_resource_len(pdev, num);
 | 
				
			||||||
		res_attr->private = &pdev->resource[num];
 | 
							res_attr->private = &pdev->resource[num];
 | 
				
			||||||
		retval = sysfs_create_bin_file(&pdev->dev.kobj, res_attr);
 | 
							retval = sysfs_create_bin_file(&pdev->dev.kobj, res_attr);
 | 
				
			||||||
 | 
							if (retval)
 | 
				
			||||||
 | 
								kfree(res_attr);
 | 
				
			||||||
	} else
 | 
						} else
 | 
				
			||||||
		retval = -ENOMEM;
 | 
							retval = -ENOMEM;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue