forked from mirrors/linux
		
	macsec: fix negative refcnt on parent link
When creation of a macsec device fails because an identical device
already exists on this link, the current code decrements the refcnt on
the parent link (in ->destructor for the macsec device), but it had not
been incremented yet.
Move the dev_hold(parent_link) call earlier during macsec device
creation.
Fixes: c09440f7dc ("macsec: introduce IEEE 802.1AE driver")
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
			
			
This commit is contained in:
		
							parent
							
								
									36b232c880
								
							
						
					
					
						commit
						0759e552bc
					
				
					 1 changed files with 2 additions and 2 deletions
				
			
		| 
						 | 
					@ -3179,6 +3179,8 @@ static int macsec_newlink(struct net *net, struct net_device *dev,
 | 
				
			||||||
	if (err < 0)
 | 
						if (err < 0)
 | 
				
			||||||
		return err;
 | 
							return err;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						dev_hold(real_dev);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* need to be already registered so that ->init has run and
 | 
						/* need to be already registered so that ->init has run and
 | 
				
			||||||
	 * the MAC addr is set
 | 
						 * the MAC addr is set
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
| 
						 | 
					@ -3207,8 +3209,6 @@ static int macsec_newlink(struct net *net, struct net_device *dev,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	macsec_generation++;
 | 
						macsec_generation++;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	dev_hold(real_dev);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
del_dev:
 | 
					del_dev:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue