Skip to contentSkip to conversation

net: Fix oops in dev_ifsioc()

PATCH Applied Jarek Poplawski 4 participants 6 messages Dec 19, 2008 – Dec 23, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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
index 048cf11..daca72e 100644
@@ -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);
#1 lore raw

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.

---

 net/core/dev.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
net/core/dev.c +0 -1
index 048cf11..daca72e 100644
@@ -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?

#2 lore raw
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.

#3 lore raw

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. :)

#4 lore raw
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