bonding/bond_main.c: check return value of
Subsystems (3)
check the return value of register_netdevice_notifier
also as attachment if something mangels the layout. compile tested
drivers/net/bonding/bond_main.c renamed from drivers/net/bonding/bond_main.c.bak +8 -1
@@ -4893,7 +4893,14 @@ }rtnl_unlock (); -register_netdevice_notifier (&bond_netdev_notifier); + + res =register_netdevice_notifier (&bond_netdev_notifier); + +if (res <0 ) { + printk( KERN_WARNING DRV_NAME" register_netdevice_notifier failed\n"); + goto out_err; + } +register_inetaddr_notifier (&bond_inetaddr_notifier);return 0 ;
drivers/net/bonding/bond_main.c renamed from drivers/net/bonding/bond_main.c.bak +8 -1
@@ -4893,7 +4893,14 @@ }rtnl_unlock (); -register_netdevice_notifier (&bond_netdev_notifier); + + res =register_netdevice_notifier (&bond_netdev_notifier); + +if (res <0 ) { + printk( KERN_WARNING DRV_NAME" register_netdevice_notifier failed\n"); + goto out_err; + } +register_inetaddr_notifier (&bond_inetaddr_notifier);return 0 ;
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
drivers/net/bonding/bond_main.c line 4900
Quoted 12 lines · walter harms
drivers/net/bonding/bond_main.c renamed from drivers/net/bonding/bond_main.c.bak +5
-1@@ -4893,7 +4893,14 @@ }rtnl_unlock (); -register_netdevice_notifier (&bond_netdev_notifier); + + res =register_netdevice_notifier (&bond_netdev_notifier); + +if (res <0 ) { + printk( KERN_WARNING DRV_NAME" register_netdevice_notifier failed\n");
This one is OK, except I don't like empty lines introduced. KERN_WARNING should KERN_ERR really.
drivers/net/bonding/bond_main.c line 4902
Quoted 2 lines
drivers/net/bonding/bond_main.c renamed from drivers/net/bonding/bond_main.c.bak +2
-0+ goto out_err; + }
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
hi list,
my next improved patch. please note
* struct net_device *bond_dev=NULL; to prevend gcc from complaining
* max_bonds is atleast 1 so i should be initialised always
* better error handling (freeing ALL resources in case of error now)
* KERN_ERR instead of KERN_WARNING
The driver does no unregister_netdevice() i did not understand why so i left it in this state. The two labels are not a mistake they simply illustrate that this is an error exit for two different errors.
alexey, if you realy do not like it, simple remove them.
re,
walter
--- linux-2.6.15.4/drivers/net/bonding/bond_main.c.bak 2006-02-10
08:22:48.000000000 +0100
+++ linux-2.6.15.4/drivers/net/bonding/bond_main.c 2006-02-25
12:36:25.000000000 +0100
@@ -4884,6 +4884,7 @@
static int __init bonding_init(void)
{
struct bond_params params;
+ struct net_device *bond_dev=NULL;
int i;
int res;
@@ -4901,7 +4902,7 @@
#endif
for (i = 0; i < max_bonds; i++) {
- struct net_device *bond_dev;
+
bond_dev = alloc_netdev(sizeof(struct bonding), "", ether_setup); if (!bond_dev) {
@@ -4929,18 +4930,29 @@
res = register_netdevice(bond_dev); if (res < 0) {
- bond_deinit(bond_dev);
- free_netdev(bond_dev);
- goto out_err;
+ goto out_no_netdevice;
}
}
rtnl_unlock();
- register_netdevice_notifier(&bond_netdev_notifier);
+ res = register_netdevice_notifier(&bond_netdev_notifier);
+ if (res < 0) {
+ printk( KERN_ERR DRV_NAME" register_netdevice_notifier failed\n");
+
+ goto out_no_nd_notifier;
+ }
+
+
register_inetaddr_notifier(&bond_inetaddr_notifier);
return 0;
+out_no_nd_notifier:
+
+out_no_netdevice:
+ bond_deinit(bond_dev);
+ free_netdev(bond_dev);
+
out_err:
/*
* rtnl_unlock() will run netdev_run_todo(), putting the
_______________________________________________
Kernel-janitors mailing list [email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
Quoted 24 lines · walter harms
hi list,
my next improved patch. please note
* structnet_device*bond_dev=NULL; to prevend gcc from complaining
*max_bondsis atleast 1 so i should be initialised always
* better error handling (freeing ALL resources in case of error now)
*KERN_ERRinstead ofKERN_WARNINGThe driver does no
unregister_netdevice()i did not understand why so i left it in this state. The two labels are not a mistake they simply illustrate that this is an error exit for two different errors.alexey, if you realy do not like it, simple remove them.
re,
walterSigned-off-by walter harms <[email protected]>--- linux-2.6.15.4/drivers/net/bonding/bond_main.c.bak 2006-02-10 08:22:48.000000000 +0100
+++linux-2.6.15.4/drivers/net/bonding/bond_main.c2006-02-25
12:36:25.000000000 +0100
Review line 4887
Quoted 4 lines
(quoted diff) +1
-0@@ -4884,6 +4884,7 @@ static int __init bonding_init(void) { struct bond_params params; + struct net_device *bond_dev=NULL;
Please observe the kernel coding style, there should be spaces around the '=' here:
struct net_device *bond_dev = NULL;
drivers/net/bonding/bond_main.c line 4906
Quoted 10 lines
drivers/net/bonding/bond_main.c renamed from drivers/net/bonding/bond_main.c.bak +1
-1int i;int res;@@ -4901,7 +4902,7 @@#endif for (i =0 ; i < max_bonds; i++) { -struct net_device *bond_dev; +
I can see the point in moving the declaration, but why insert a blank line? if anything I'd say you should be removing the blank line that's already there, like so :
- struct net_device *bond_dev;
-
Quoted 20 lines
(quoted diff) +6
-4bond_dev = alloc_netdev(sizeof(struct bonding), "", ether_setup); if (!bond_dev) {@@ -4929,18 +4930,29 @@ res = register_netdevice(bond_dev); if (res < 0) { - bond_deinit(bond_dev); - free_netdev(bond_dev); - goto out_err; + goto out_no_netdevice; } } rtnl_unlock(); - register_netdevice_notifier(&bond_netdev_notifier); + res = register_netdevice_notifier(&bond_netdev_notifier); + if (res < 0) { + printk( KERN_ERR DRV_NAME" register_netdevice_notifier failed\n"); + + goto out_no_nd_notifier;
Review line 4952
Quoted 10 lines
(quoted diff) +6
-0+ } + + register_inetaddr_notifier(&bond_inetaddr_notifier); return 0; +out_no_nd_notifier: + +out_no_netdevice:
personally I'd just collapse the two labels into a single label.
Review line 4958
Quoted 6 lines
(quoted diff) +3
-0+ bond_deinit(bond_dev); + free_netdev(bond_dev); + out_err: /* * rtnl_unlock() will run netdev_run_todo(), putting the
--
Jesper Juhl <[email protected]>
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
drivers/net/bonding/bond_main.c line 4904
Quoted 9 lines · walter harms
drivers/net/bonding/bond_main.c renamed from drivers/net/bonding/bond_main.c.bak +8
-0+ res =register_netdevice_notifier (&bond_netdev_notifier); +if (res <0 ) { + printk( KERN_ERR DRV_NAME" register_netdevice_notifier failed\n"); + + goto out_no_nd_notifier; + } + +register_inetaddr_notifier (&bond_inetaddr_notifier);
I don't think there's a reason for that double newline.
Tim
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
Quoted 6 lines
hi list,
my next improved patch. please note
* structnet_device*bond_dev=NULL; to prevend gcc from complaining
*max_bondsis atleast 1 so i should be initialised always
* better error handling (freeing ALL resources in case of error now)
*KERN_ERRinstead ofKERN_WARNING
* less lines more space :)
Quoted 8 lines
The driver does no
unregister_netdevice()i did not understand why so i left it in this state. The two labels are not a mistake they simply illustrate that this is an error exit for two different errors. alexey, if you realy do not like it, simple remove them.re,
walter
ps:
i admit i did not test-compile it since it is only a fmt issue.
--- linux-2.6.15.4/drivers/net/bonding/bond_main.c.bak 2006-02-10
08:22:48.000000000 +0100
+++ linux-2.6.15.4/drivers/net/bonding/bond_main.c 2006-02-25
13:36:10.000000000 +0100
@@ -4884,6 +4884,7 @@
static int __init bonding_init(void)
{
struct bond_params params;
+ struct net_device *bond_dev = NULL;
int i;
int res;
@@ -4901,8 +4902,6 @@
#endif
for (i = 0; i < max_bonds; i++) {
- struct net_device *bond_dev;
-
bond_dev = alloc_netdev(sizeof(struct bonding), "", ether_setup); if (!bond_dev) {
res = -ENOMEM;
@@ -4929,18 +4928,29 @@
res = register_netdevice(bond_dev); if (res < 0) {
- bond_deinit(bond_dev);
- free_netdev(bond_dev);
- goto out_err;
+ goto out_no_netdevice;
}
}
rtnl_unlock();
- register_netdevice_notifier(&bond_netdev_notifier);
+ res = register_netdevice_notifier(&bond_netdev_notifier);
+ if (res < 0) {
+ printk( KERN_ERR DRV_NAME" register_netdevice_notifier failed\n");
+
+ goto out_no_nd_notifier;
+ }
+
+
register_inetaddr_notifier(&bond_inetaddr_notifier);
return 0;
+out_no_nd_notifier:
+
+out_no_netdevice:
+ bond_deinit(bond_dev);
+ free_netdev(bond_dev);
+
out_err:
/*
* rtnl_unlock() will run netdev_run_todo(), putting the
_______________________________________________
Kernel-janitors mailing list [email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
Quoted 12 lines · Tim Cooijmans
drivers/net/bonding/bond_main.c line 4904
Quoted 9 lines · walter harms
drivers/net/bonding/bond_main.c renamed from drivers/net/bonding/bond_main.c.bak +8
-0+ res =register_netdevice_notifier (&bond_netdev_notifier); +if (res <0 ) { + printk( KERN_ERR DRV_NAME" register_netdevice_notifier failed\n"); + + goto out_no_nd_notifier; + } + +register_inetaddr_notifier (&bond_inetaddr_notifier);I don't think there's a reason for that double newline.
I'd agree, and IMHO the one above the goto should go as well.
--
Jesper Juhl <[email protected]>
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors