mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	usb: gadget: f_fs: Stop ffs_closed NULL pointer dereference
The struct ffs_data::private_data has a pointer to ffs_dev stored in it during the ffs_fs_mount() function however it is not cleared when the ffs_dev is freed later which causes the ffs_closed function to crash with "Unable to handle kernel NULL pointer dereference" error when using the data in ffs_data::private_data. This clears this pointer during the ffs_free_dev clean up function. Signed-off-by: Jim Baxter <jim_baxter@mentor.com> Signed-off-by: Jiada Wang <jiada_wang@mentor.com> Signed-off-by: Harish Jenny K N <harish_kandiga@mentor.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
This commit is contained in:
		
							parent
							
								
									9d6173e125
								
							
						
					
					
						commit
						3262ad8243
					
				
					 1 changed files with 5 additions and 0 deletions
				
			
		| 
						 | 
					@ -3502,6 +3502,11 @@ static void _ffs_free_dev(struct ffs_dev *dev)
 | 
				
			||||||
	list_del(&dev->entry);
 | 
						list_del(&dev->entry);
 | 
				
			||||||
	if (dev->name_allocated)
 | 
						if (dev->name_allocated)
 | 
				
			||||||
		kfree(dev->name);
 | 
							kfree(dev->name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* Clear the private_data pointer to stop incorrect dev access */
 | 
				
			||||||
 | 
						if (dev->ffs_data)
 | 
				
			||||||
 | 
							dev->ffs_data->private_data = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	kfree(dev);
 | 
						kfree(dev);
 | 
				
			||||||
	if (list_empty(&ffs_devices))
 | 
						if (list_empty(&ffs_devices))
 | 
				
			||||||
		functionfs_cleanup();
 | 
							functionfs_cleanup();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue