linux-2.6.9: add errorcheck for netlink
Subsystems (2)
Hi list,
i moved the netlink patches from 2.6.7 to 2.6.9.
it adds 2 error checks.
1. register_netdevice_notifier()
2. sock_register()
To propagate the error i changed the type from void to int.
re,
walter
--- linux-2.6.9/net/core/rtnetlink.c.bak 2004-11-26
22:11:15.000000000 +0100
+++ linux-2.6.9/net/core/rtnetlink.c 2004-11-26 23:22:00.000000000 +0100
@@ -653,7 +653,7 @@
.notifier_call = rtnetlink_event,
};
-void __init rtnetlink_init(void)
+int __init rtnetlink_init(void)
{
int i;
@@ -661,17 +661,34 @@
for (i = 0; i < ARRAY_SIZE(rta_max); i++)
if (rta_max[i] > rtattr_max)
rtattr_max = rta_max[i];
+
rta_buf = kmalloc(rtattr_max * sizeof(struct rtattr *), GFP_KERNEL);
- if (!rta_buf)
- panic("rtnetlink_init: cannot allocate rta_buf\n");
+ if (!rta_buf) {
+ printk(KERN_CRIT "%s: cannot allocate rta_buf\n",__FUNCTION__);
+ goto no_mem;
+ }
rtnl = netlink_kernel_create(NETLINK_ROUTE, rtnetlink_rcv);
- if (rtnl == NULL)
- panic("rtnetlink_init: cannot initialize rtnetlink\n");
+ if (rtnl == NULL) {
+ printk(KERN_CRIT "%s: cannot initialize rtnetlink\n",__FUNCTION__);
+ goto no_netlink;
+ }
netlink_set_nonroot(NETLINK_ROUTE, NL_NONROOT_RECV);
- register_netdevice_notifier(&rtnetlink_dev_notifier);
+
+ if ( register_netdevice_notifier(&rtnetlink_dev_notifier) < 0 ) {
+
+ printk(KERN_ERR "%s: cannot initialize rtnetlink notifier\n",__FUNCTION__);
+ goto no_netlink;
+ }
+
rtnetlink_links[PF_UNSPEC] = link_rtnetlink_table; rtnetlink_links[PF_PACKET] = link_rtnetlink_table;
+ return 0;
+
+no_netlink:
+ kfree(rtnl);
+no_mem:
+ return -1;
}
EXPORT_SYMBOL(__rta_fill);
include/linux/rtnetlink.h renamed from include/linux/rtnetlink.h.bak +1 -1
@@ -805,7 +805,7 @@extern void rtnl_lock (void );extern void rtnl_unlock (void ); -extern void rtnetlink_init (void ); +extern int rtnetlink_init (void );#define ASSERT_RTNL () do { \ if (unlikely(down_trylock(&rtnl_sem) == 0)) { \
net/netlink/af_netlink.c renamed from net/netlink/af_netlink.c.bak +37 -15
66 lines not on this page · raw message
_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors