From: Jarek Poplawski Date: Tue, 23 Dec 2008 03:35:28 +0000 (-0800) Subject: net: Fix oops in dev_ifsioc() X-Git-Tag: v2.6.29-rc1~581^2~95 X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=5f2f6da76c429c42d54f73807f00b8fd761a7d68;p=linux.git net: Fix oops in dev_ifsioc() A command like this: "brctl addif br1 eth1" issued as a user gave me an oops when bridge module wasn't loaded. It's caused by using a dev pointer before checking for NULL. Signed-off-by: Jarek Poplawski Signed-off-by: David S. Miller --- diff --git a/net/core/dev.c b/net/core/dev.c index 048cf1197872..daca72e6b37b 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3745,11 +3745,13 @@ static int dev_ifsioc(struct net *net, struct ifreq *ifr, unsigned int cmd) { int err; struct net_device *dev = __dev_get_by_name(net, ifr->ifr_name); - const struct net_device_ops *ops = dev->netdev_ops; + const struct net_device_ops *ops; if (!dev) return -ENODEV; + ops = dev->netdev_ops; + switch (cmd) { case SIOCSIFFLAGS: /* Set interface flags */ return dev_change_flags(dev, ifr->ifr_flags);