aboutsummaryrefslogtreecommitdiffstats
path: root/net/dccp/proto.c
diff options
context:
space:
mode:
authorGerrit Renker <gerrit@erg.abdn.ac.uk>2010-03-14 16:13:19 -0400
committerDavid S. Miller <davem@davemloft.net>2010-03-15 19:00:50 -0400
commitd14a0ebda7d3daede1a99c01527affb9ceaa4c22 (patch)
tree8bee27033c0e771a9df0c3e8cc3f1dc1091587f0 /net/dccp/proto.c
parentb8d689743106bab5c49dda87080e76aa78db8a56 (diff)
net-2.6 [Bug-Fix][dccp]: fix oops caused after failed initialisation
dccp: fix panic caused by failed initialisation This fixes a kernel panic reported thanks to Andre Noll: if DCCP is compiled into the kernel and any out of the initialisation steps in net/dccp/proto.c:dccp_init() fail, a subsequent attempt to create a SOCK_DCCP socket will panic, since inet{,6}_create() are not prevented from creating DCCP sockets. This patch fixes the problem by propagating a failure in dccp_init() to dccp_v{4,6}_init_net(), and from there to dccp_v{4,6}_init(), so that the DCCP protocol is not made available if its initialisation fails. Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dccp/proto.c')
-rw-r--r--net/dccp/proto.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/net/dccp/proto.c b/net/dccp/proto.c
index 0ef7061920c0..aa4cef374fd0 100644
--- a/net/dccp/proto.c
+++ b/net/dccp/proto.c
@@ -1036,7 +1036,7 @@ static int __init dccp_init(void)
1036 FIELD_SIZEOF(struct sk_buff, cb)); 1036 FIELD_SIZEOF(struct sk_buff, cb));
1037 rc = percpu_counter_init(&dccp_orphan_count, 0); 1037 rc = percpu_counter_init(&dccp_orphan_count, 0);
1038 if (rc) 1038 if (rc)
1039 goto out; 1039 goto out_fail;
1040 rc = -ENOBUFS; 1040 rc = -ENOBUFS;
1041 inet_hashinfo_init(&dccp_hashinfo); 1041 inet_hashinfo_init(&dccp_hashinfo);
1042 dccp_hashinfo.bind_bucket_cachep = 1042 dccp_hashinfo.bind_bucket_cachep =
@@ -1125,8 +1125,9 @@ static int __init dccp_init(void)
1125 goto out_sysctl_exit; 1125 goto out_sysctl_exit;
1126 1126
1127 dccp_timestamping_init(); 1127 dccp_timestamping_init();
1128out: 1128
1129 return rc; 1129 return 0;
1130
1130out_sysctl_exit: 1131out_sysctl_exit:
1131 dccp_sysctl_exit(); 1132 dccp_sysctl_exit();
1132out_ackvec_exit: 1133out_ackvec_exit:
@@ -1135,18 +1136,19 @@ out_free_dccp_mib:
1135 dccp_mib_exit(); 1136 dccp_mib_exit();
1136out_free_dccp_bhash: 1137out_free_dccp_bhash:
1137 free_pages((unsigned long)dccp_hashinfo.bhash, bhash_order); 1138 free_pages((unsigned long)dccp_hashinfo.bhash, bhash_order);
1138 dccp_hashinfo.bhash = NULL;
1139out_free_dccp_locks: 1139out_free_dccp_locks:
1140 inet_ehash_locks_free(&dccp_hashinfo); 1140 inet_ehash_locks_free(&dccp_hashinfo);
1141out_free_dccp_ehash: 1141out_free_dccp_ehash:
1142 free_pages((unsigned long)dccp_hashinfo.ehash, ehash_order); 1142 free_pages((unsigned long)dccp_hashinfo.ehash, ehash_order);
1143 dccp_hashinfo.ehash = NULL;
1144out_free_bind_bucket_cachep: 1143out_free_bind_bucket_cachep:
1145 kmem_cache_destroy(dccp_hashinfo.bind_bucket_cachep); 1144 kmem_cache_destroy(dccp_hashinfo.bind_bucket_cachep);
1146 dccp_hashinfo.bind_bucket_cachep = NULL;
1147out_free_percpu: 1145out_free_percpu:
1148 percpu_counter_destroy(&dccp_orphan_count); 1146 percpu_counter_destroy(&dccp_orphan_count);
1149 goto out; 1147out_fail:
1148 dccp_hashinfo.bhash = NULL;
1149 dccp_hashinfo.ehash = NULL;
1150 dccp_hashinfo.bind_bucket_cachep = NULL;
1151 return rc;
1150} 1152}
1151 1153
1152static void __exit dccp_fini(void) 1154static void __exit dccp_fini(void)