mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-01 00:58:39 +02:00 
			
		
		
		
	tpm: Fix initialization of the cdev
When a cdev is contained in a dynamic structure the cdev parent kobj
should be set to the kobj that controls the lifetime of the enclosing
structure. In TPM's case this is the embedded struct device.
Also, cdev_init 0's the whole structure, so all sets must be after,
not before. This fixes module ref counting and cdev.
Cc: <stable@vger.kernel.org>
Fixes: 313d21eeab ("tpm: device class for tpm")
Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
			
			
This commit is contained in:
		
							parent
							
								
									b3bddffd35
								
							
						
					
					
						commit
						ba0ef85479
					
				
					 1 changed files with 2 additions and 1 deletions
				
			
		|  | @ -129,8 +129,9 @@ struct tpm_chip *tpmm_chip_alloc(struct device *dev, | |||
| 
 | ||||
| 	device_initialize(&chip->dev); | ||||
| 
 | ||||
| 	chip->cdev.owner = chip->pdev->driver->owner; | ||||
| 	cdev_init(&chip->cdev, &tpm_fops); | ||||
| 	chip->cdev.owner = chip->pdev->driver->owner; | ||||
| 	chip->cdev.kobj.parent = &chip->dev.kobj; | ||||
| 
 | ||||
| 	return chip; | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue
	
	 Jason Gunthorpe
						Jason Gunthorpe