Skip to contentSkip to conversation

netlink oops fix due to incorrect error code

PATCH In review Kirill Korotaev 5 participants 5 messages Jan 9, 2006 – Jan 10, 2006

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

PATCH 1/1 netlink oops fix due to incorrect error code

Fixed oops after failed netlink socket creation. Wrong parathenses in if() statement caused err to be 1, instead of negative value.
Trivial fix, not trivial to find though.

Kirill
P.S. against 2.6.15

net/netlink/af_netlink.c renamed from net/netlink/af_netlink.c.nlfix +1 -1
@@ -416,7 +416,7 @@ static int netlink_create(struct socket 
 	groups = nl_table[protocol].groups;
 	netlink_unlock_table();
 
-	if ((err = __netlink_create(sock, protocol) < 0))
+	if ((err = __netlink_create(sock, protocol)) < 0)
 		goto out_module;
 
 	nlk = nlk_sk(sock->sk);
#1 lore raw

PATCH 1/1 Fix more "if ((err = foo() < 0))" typos

Another reason to use:

	ret = foo();
	if (ret < 0)
		goto out;

---

 Documentation/kprobes.txt           |    3 ++-
 arch/mips/kernel/vpe.c              |    3 ++-
 drivers/media/dvb/frontends/mt312.c |    3 ++-
 3 files changed, 6 insertions(+), 3 deletions(-)
Documentation/kprobes.txt +2 -1
diff -uprN linux-vanilla/Documentation/kprobes.txt linux-1/Documentation/kprobes.txt
@@ -411,7 +411,8 @@ int init_module(void)
 		printk("Couldn't find %s to plant kprobe\n", "do_fork");
 		return -1;
 	}
-	if ((ret = register_kprobe(&kp) < 0)) {
+	ret = register_kprobe(&kp);
+	if (ret < 0) {
 		printk("register_kprobe failed, returned %d\n", ret);
 		return -1;
 	}
arch/mips/kernel/vpe.c +2 -1
diff -uprN linux-vanilla/arch/mips/kernel/vpe.c linux-1/arch/mips/kernel/vpe.c
@@ -1171,7 +1171,8 @@ static int __init vpe_module_init(void)
 		return -ENODEV;
 	}
 
-	if ((major = register_chrdev(0, module_name, &vpe_fops) < 0)) {
+	major = register_chrdev(0, module_name, &vpe_fops);
+	if (major < 0) {
 		printk("VPE loader: unable to register character device\n");
 		return major;
 	}
drivers/media/dvb/frontends/mt312.c +2 -1
diff -uprN linux-vanilla/drivers/media/dvb/frontends/mt312.c linux-1/drivers/media/dvb/frontends/mt312.c
@@ -501,7 +501,8 @@ static int mt312_set_frontend(struct dvb
 	case ID_VP310:
 	// For now we will do this only for the VP310.
 	// It should be better for the mt312 as well, but tunning will be slower. ACCJr 09/29/03
-		if ((ret = mt312_readreg(state, CONFIG, &config_val) < 0))
+		ret = mt312_readreg(state, CONFIG, &config_val);
+		if (ret < 0)
 			return ret;
 		if (p->u.qpsk.symbol_rate >= 30000000) //Note that 30MS/s should use 90MHz
 		{
#2 lore raw
In reply to Kirill Korotaev
Quoted 7 lines · Kirill Korotaev

Fixed oops after failed netlink socket creation. Wrong parathenses in if() statement caused err to be 1, instead of negative value.
Trivial fix, not trivial to find though.

Good catch. Dave, please apply.

Quoted 15 lines

------------------------------------------------------------------------

net/netlink/af_netlink.c renamed from net/netlink/af_netlink.c.nlfix +1 -1
@@ -416,7 +416,7 @@ static int netlink_create(struct socket 
 	groups = nl_table[protocol].groups;
 	netlink_unlock_table();
 
-	if ((err = __netlink_create(sock, protocol) < 0))
+	if ((err = __netlink_create(sock, protocol)) < 0)
 		goto out_module;
 
 	nlk = nlk_sk(sock->sk);
maintainer
#3 lore raw

From: Patrick McHardy <[email protected]>
Date: Tue, 10 Jan 2006 00:50:52 +0100

Quoted 10 lines
Quoted 7 lines · Kirill Korotaev

Fixed oops after failed netlink socket creation. Wrong parathenses in if() statement caused err to be 1, instead of negative value.
Trivial fix, not trivial to find though.

Good catch. Dave, please apply.

Already in Linus's tree, he applied it directly :-)

#4 lore raw
In reply to Kirill Korotaev
Quoted 4 lines · * Kirill Korotaev ([email protected]) wrote:

Fixed oops after failed netlink socket creation. Wrong parathenses in if() statement caused err to be 1, instead of negative value.
Trivial fix, not trivial to find though.

Thanks, queued to -stable.
-chris