From: Sabrina Dubroca Date: Fri, 29 Jul 2016 13:37:55 +0000 (+0200) Subject: macsec: fix negative refcnt on parent link X-Git-Tag: v4.1.12-92~3^2~251 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=cfd42a7c5a289626242bc19258311222a2c853a1;p=users%2Fjedix%2Flinux-maple.git macsec: fix negative refcnt on parent link Orabug: 25243093 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: c09440f7dcb3 ("macsec: introduce IEEE 802.1AE driver") Signed-off-by: Sabrina Dubroca Signed-off-by: David S. Miller (cherry picked from commit 0759e552bce7257db542e203a01a9ef8843c751e) Signed-off-by: Ethan Zhao --- diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c index cabbf675344a5..727c131a0b831 100644 --- a/drivers/net/macsec.c +++ b/drivers/net/macsec.c @@ -3114,6 +3114,8 @@ static int macsec_newlink(struct net *net, struct net_device *dev, if (err < 0) return err; + dev_hold(real_dev); + /* need to be already registered so that ->init has run and * the MAC addr is set */ @@ -3142,8 +3144,6 @@ static int macsec_newlink(struct net *net, struct net_device *dev, macsec_generation++; - dev_hold(real_dev); - return 0; del_dev: