]> git.hungrycats.org Git - linux/commitdiff
ppp: Fix null pointer dereference on registration failure
authorBen Hutchings <ben@decadent.org.uk>
Fri, 12 Oct 2018 19:58:04 +0000 (20:58 +0100)
committerBen Hutchings <ben@decadent.org.uk>
Sun, 21 Oct 2018 07:46:19 +0000 (08:46 +0100)
register_netdevice() will call the device's ndo_uninit operation if
registration fails after it calls the ndo_init operation.  However
ppp_dev_uninit() uses ppp->ppp_net which is currently not set until
after register_netdevice() returns.

This was fixed upstream as part of commit 96d934c70db6 "ppp: add
rtnetlink device creation support".

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/net/ppp/ppp_generic.c

index 0a47788a4fc8f8982ffcfd44c9e9f85cd25db16a..b88886f0d10379c441eb617ba579ba804fcf56ff 100644 (file)
@@ -2732,6 +2732,7 @@ static struct ppp *ppp_create_interface(struct net *net, int unit,
 
        ppp = netdev_priv(dev);
        ppp->dev = dev;
+       ppp->ppp_net = net;
        ppp->mru = PPP_MRU;
        init_ppp_file(&ppp->file, INTERFACE);
        ppp->file.hdrlen = PPP_HDRLEN - 2;      /* don't count proto bytes */
@@ -2801,8 +2802,6 @@ static struct ppp *ppp_create_interface(struct net *net, int unit,
                goto out2;
        }
 
-       ppp->ppp_net = net;
-
        atomic_inc(&ppp_unit_count);
        mutex_unlock(&pn->all_ppp_mutex);
        rtnl_unlock();