mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	i2c: core: fix use after free in of_i2c_notify
We can't use "adap->dev" after it has been freed.
Fixes: 5bf4fa7dae ("i2c: break out OF support into separate file")
Signed-off-by: Wen Yang <wenyang@linux.alibaba.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
			
			
This commit is contained in:
		
							parent
							
								
									7574c0db2e
								
							
						
					
					
						commit
						a4c2fec16f
					
				
					 1 changed files with 2 additions and 2 deletions
				
			
		| 
						 | 
					@ -245,14 +245,14 @@ static int of_i2c_notify(struct notifier_block *nb, unsigned long action,
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		client = of_i2c_register_device(adap, rd->dn);
 | 
							client = of_i2c_register_device(adap, rd->dn);
 | 
				
			||||||
		put_device(&adap->dev);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		if (IS_ERR(client)) {
 | 
							if (IS_ERR(client)) {
 | 
				
			||||||
			dev_err(&adap->dev, "failed to create client for '%pOF'\n",
 | 
								dev_err(&adap->dev, "failed to create client for '%pOF'\n",
 | 
				
			||||||
				 rd->dn);
 | 
									 rd->dn);
 | 
				
			||||||
 | 
								put_device(&adap->dev);
 | 
				
			||||||
			of_node_clear_flag(rd->dn, OF_POPULATED);
 | 
								of_node_clear_flag(rd->dn, OF_POPULATED);
 | 
				
			||||||
			return notifier_from_errno(PTR_ERR(client));
 | 
								return notifier_from_errno(PTR_ERR(client));
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							put_device(&adap->dev);
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	case OF_RECONFIG_CHANGE_REMOVE:
 | 
						case OF_RECONFIG_CHANGE_REMOVE:
 | 
				
			||||||
		/* already depopulated? */
 | 
							/* already depopulated? */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue