Skip to contentSkip to conversation

bonding: fix panic if initialization fails

PATCH Applied Florian Westphal 4 participants 6 messages May 8, 2009 – May 9, 2009

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

PATCH 1/1 bonding: fix panic if initialization fails

If module initialisation failed (e.g. because the bonding sysfs entry cannot be created), kernel panics:
IP: [<ffffffff8024910a>] destroy_workqueue+0x2d/0x146

Call Trace:
 [<ffffffff808268c4>] bond_destructor+0x28/0x78
 [<ffffffff80b64471>] netdev_run_todo+0x231/0x25a
 [<ffffffff80b6dbcd>] rtnl_unlock+0x9/0xb
 [<ffffffff81567907>] bonding_init+0x83e/0x84a

Remove the calls to bond_work_cancel_all() and destroy_workqueue(); both are also called/scheduled via bond_free_all().

bond_destroy_sysfs is unecessary because the sysfs entry has not been created in the error case.

---
 drivers/net/bonding/bond_main.c |    8 --------
 1 files changed, 0 insertions(+), 8 deletions(-)
drivers/net/bonding/bond_main.c +0 -8
index 815191d..56830a4 100644
@@ -5199,7 +5199,6 @@ static int __init bonding_init(void)
 {
 	int i;
 	int res;
-	struct bonding *bond;
 
 	printk(KERN_INFO "%s", version);
 
@@ -5228,13 +5227,6 @@ static int __init bonding_init(void)
 
 	goto out;
 err:
-	list_for_each_entry(bond, &bond_dev_list, bond_list) {
-		bond_work_cancel_all(bond);
-		destroy_workqueue(bond->wq);
-	}
-
-	bond_destroy_sysfs();
-
 	rtnl_lock();
 	bond_free_all();
 	rtnl_unlock();
Signature · 1 line
1.6.0.6
#1 lore raw
Quoted 9 lines · Florian Westphal

If module initialisation failed (e.g. because the bonding sysfs entry cannot be created), kernel panics:
IP: [<ffffffff8024910a>] destroy_workqueue+0x2d/0x146

Call Trace:
[<ffffffff808268c4>] bond_destructor+0x28/0x78
[<ffffffff80b64471>] netdev_run_todo+0x231/0x25a
[<ffffffff80b6dbcd>] rtnl_unlock+0x9/0xb
[<ffffffff81567907>] bonding_init+0x83e/0x84a
Quoted 7 lines

Remove the calls to bond_work_cancel_all() and destroy_workqueue(); both are also called/scheduled via bond_free_all().

bond_destroy_sysfs is unecessary because the sysfs entry has not been created in the error case.

Looks good to me.

	-J
Quoted 31 lines

drivers/net/bonding/bond_main.c | 8 --------

1 files changed, 0 insertions(+), 8 deletions(-)
drivers/net/bonding/bond_main.c +0 -1
index 815191d..56830a4 100644
@@ -5199,7 +5199,6 @@ static int __init bonding_init(void)
 {
 	int i;
 	int res;
-	struct bonding *bond;
 
 	printk(KERN_INFO "%s", version);
 
@@ -5228,13 +5227,6 @@ static int __init bonding_init(void)
 
 	goto out;

err:

drivers/net/bonding/bond_main.c +0 -7
-	list_for_each_entry(bond, &bond_dev_list, bond_list) {
-		bond_work_cancel_all(bond);
-		destroy_workqueue(bond->wq);
-	}
-
-	bond_destroy_sysfs();
-
	rtnl_lock();
	bond_free_all();
	rtnl_unlock();
Signature · 1 line
1.6.0.6
#2 lore raw
In reply to Florian Westphal
Quoted 36 lines · Fri, May 08, 2009 at 11:49:11PM CEST, [email protected] wrote:

If module initialisation failed (e.g. because the bonding sysfs entry cannot be created), kernel panics:
IP: [<ffffffff8024910a>] destroy_workqueue+0x2d/0x146

Call Trace:
[<ffffffff808268c4>] bond_destructor+0x28/0x78
[<ffffffff80b64471>] netdev_run_todo+0x231/0x25a
[<ffffffff80b6dbcd>] rtnl_unlock+0x9/0xb
[<ffffffff81567907>] bonding_init+0x83e/0x84a

Remove the calls to bond_work_cancel_all() and destroy_workqueue(); both are also called/scheduled via bond_free_all().

bond_destroy_sysfs is unecessary because the sysfs entry has not been created in the error case.

---
drivers/net/bonding/bond_main.c | 8 --------

1 files changed, 0 insertions(+), 8 deletions(-)
drivers/net/bonding/bond_main.c +0 -1
index 815191d..56830a4 100644
@@ -5199,7 +5199,6 @@ static int __init bonding_init(void)
 {
 	int i;
 	int res;
-	struct bonding *bond;
 
 	printk(KERN_INFO "%s", version);
 
@@ -5228,13 +5227,6 @@ static int __init bonding_init(void)
 
 	goto out;

err:

drivers/net/bonding/bond_main.c static int __init bonding_init(void) · line 5234

Quoted 4 lines
drivers/net/bonding/bond_main.c +0 -4
-	list_for_each_entry(bond, &bond_dev_list, bond_list) {
-		bond_work_cancel_all(bond);
-		destroy_workqueue(bond->wq);
-	}

This looks correct.

drivers/net/bonding/bond_main.c static int __init bonding_init(void) · line 5236

Quoted 2 lines
drivers/net/bonding/bond_main.c +0 -2
-
-	bond_destroy_sysfs();

Why this is not here anymore? I think it should be called in this function.

Quoted 11 lines

-

	rtnl_lock();
	bond_free_all();
	rtnl_unlock();
Signature · 6 lines
1.6.0.6

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#3 lore raw
Quoted 10 lines · Jiri Pirko

drivers/net/bonding/bond_main.c static int __init bonding_init(void) · line 5234

Quoted 5 lines

err:

drivers/net/bonding/bond_main.c +0 -4
-	list_for_each_entry(bond, &bond_dev_list, bond_list) {
-		bond_work_cancel_all(bond);
-		destroy_workqueue(bond->wq);
-	}

This looks correct.

drivers/net/bonding/bond_main.c static int __init bonding_init(void) · line 5236

Quoted 2 lines
drivers/net/bonding/bond_main.c +0 -2
-
-	bond_destroy_sysfs();

Why this is not here anymore? I think it should be called in this function.

Thanks for reviewing.
I removed it because, if you hit this error path, sysfs registration failed, so there is no entry to remove.

Its not a bug to call it though (sysfs_hash_and_remove() returns -ENOENT in that case), and i can re-spin without that change if you want.

#4 lore raw
Quoted 8 lines · Sat, May 09, 2009 at 01:30:57AM CEST, [email protected] wrote:
Quoted 7 lines · Jiri Pirko

drivers/net/bonding/bond_main.c static int __init bonding_init(void) · line 5234

Quoted 5 lines

err:

drivers/net/bonding/bond_main.c +0 -4
-	list_for_each_entry(bond, &bond_dev_list, bond_list) {
-		bond_work_cancel_all(bond);
-		destroy_workqueue(bond->wq);
-	}

This looks correct.

Quoted 7 lines
Quoted 3 lines

drivers/net/bonding/bond_main.c static int __init bonding_init(void) · line 5236

Quoted 2 lines
drivers/net/bonding/bond_main.c +0 -2
-
-	bond_destroy_sysfs();

Why this is not here anymore? I think it should be called in this function.

Thanks for reviewing.
I removed it because, if you hit this error path, sysfs registration failed, so there is no entry to remove.

Yes, you are rigth.

Quoted 8 lines

Its not a bug to call it though
(sysfs_hash_and_remove() returns -ENOENT in that case), and i can re-spin without that change if you want.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer Applied
#5 lore raw

From: Jiri Pirko <[email protected]>
Date: Sat, 9 May 2009 01:36:04 +0200

Quoted 13 lines
Quoted 12 lines · Sat, May 09, 2009 at 01:30:57AM CEST, [email protected] wrote:
Quoted 10 lines · Jiri Pirko

drivers/net/bonding/bond_main.c static int __init bonding_init(void) · line 5234

Quoted 5 lines

err:

drivers/net/bonding/bond_main.c +0 -4
-	list_for_each_entry(bond, &bond_dev_list, bond_list) {
-		bond_work_cancel_all(bond);
-		destroy_workqueue(bond->wq);
-	}

This looks correct.

drivers/net/bonding/bond_main.c static int __init bonding_init(void) · line 5236

Quoted 2 lines
drivers/net/bonding/bond_main.c +0 -2
-
-	bond_destroy_sysfs();

Why this is not here anymore? I think it should be called in this function.

Quoted 7 lines
Quoted 3 lines

Thanks for reviewing.
I removed it because, if you hit this error path, sysfs registration failed, so there is no entry to remove.

Yes, you are right.

Applied, thanks!