net: Fix oops in dev_ifsioc()
Subsystems (2)
PATCH 1/1 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.
---
net/core/dev.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
net/core/dev.c +3 -1
@@ -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);
Jarek Poplawski said the following on 2008-12-19 15:04:
Quoted 19 lines
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 <[email protected]>---
net/core/dev.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)net/core/dev.c +0
-1@@ -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;
net/core/dev.c static int dev_ifsioc(struct net *net, struct ifreq *ifr, unsigned int cmd) · line 3757
Quoted 10 lines
net/core/dev.c +3
-0+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);
Subject will be changed, sorry.
Seems Julia is doing "Move a dereference below a NULL test" check, but why the coccinelle missed this one?
Quoted 4 lines · Wang Chen
Jarek Poplawski said the following on 2008-12-19 15:04:
Quoted 3 lines
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.
...
Quoted 3 lines
Subject will be changed, sorry.
Seems Julia is doing "Move a dereference below a NULL test" check, but why the coccinelle missed this one?
Probably because it's quite fresh?
Jarek P.
Jarek Poplawski said the following on 2008-12-19 16:11:
Quoted 5 lines · Wang Chen
Quoted 4 lines
Jarek Poplawski said the following on 2008-12-19 15:04:
Quoted 3 lines
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.
Quoted 7 lines
...
Quoted 3 lines
Subject will be changed, sorry.
Seems Julia is doing "Move a dereference below a NULL test" check, but why the coccinelle missed this one?Probably because it's quite fresh?
Yes. Maybe Julia never check the source of -next. :)
Quoted 7 lines · Wang Chen
Jarek Poplawski said the following on 2008-12-19 16:11:
Quoted 6 lines · Wang Chen
Quoted 4 lines
Jarek Poplawski said the following on 2008-12-19 15:04:
Quoted 3 lines
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.
...
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Subject will be changed, sorry.
Seems Julia is doing "Move a dereference below a NULL test" check, but why the coccinelle missed this one?Probably because it's quite fresh?
Yes. Maybe Julia never check the source of -next. :)
Sorry, my -next was mysteriously quite out of date. It's up to date now. Indeed, I found that one just now.
julia
From: Jarek Poplawski <[email protected]>
Date: Fri, 19 Dec 2008 07:04:31 +0000
Quoted 5 lines
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 <[email protected]>
Applied, thanks Jarek.