diff options
author | Dan Carpenter <error27@gmail.com> | 2011-08-30 15:16:15 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2011-09-13 15:48:48 -0400 |
commit | 4c5ade414912cd903906339491675352bfccbdfe (patch) | |
tree | e3be0b7ff13dc818eba3a3794d45159d636845e8 /net | |
parent | edf6b784c0e574696915e7b04fe42158f3112d0d (diff) |
mac80211: handle allocation failures in mesh_pathtbl_init()
The calls to kzalloc() weren't checked here and it upsets the static
checkers. Obviously they're not super likely to fail, but we might
as well add some error handling.
Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/mac80211/mesh_pathtbl.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/net/mac80211/mesh_pathtbl.c b/net/mac80211/mesh_pathtbl.c index a66a2cab8d34..55a206cfb8cc 100644 --- a/net/mac80211/mesh_pathtbl.c +++ b/net/mac80211/mesh_pathtbl.c | |||
@@ -1095,6 +1095,7 @@ static int mesh_path_node_copy(struct hlist_node *p, struct mesh_table *newtbl) | |||
1095 | int mesh_pathtbl_init(void) | 1095 | int mesh_pathtbl_init(void) |
1096 | { | 1096 | { |
1097 | struct mesh_table *tbl_path, *tbl_mpp; | 1097 | struct mesh_table *tbl_path, *tbl_mpp; |
1098 | int ret; | ||
1098 | 1099 | ||
1099 | tbl_path = mesh_table_alloc(INIT_PATHS_SIZE_ORDER); | 1100 | tbl_path = mesh_table_alloc(INIT_PATHS_SIZE_ORDER); |
1100 | if (!tbl_path) | 1101 | if (!tbl_path) |
@@ -1103,18 +1104,26 @@ int mesh_pathtbl_init(void) | |||
1103 | tbl_path->copy_node = &mesh_path_node_copy; | 1104 | tbl_path->copy_node = &mesh_path_node_copy; |
1104 | tbl_path->mean_chain_len = MEAN_CHAIN_LEN; | 1105 | tbl_path->mean_chain_len = MEAN_CHAIN_LEN; |
1105 | tbl_path->known_gates = kzalloc(sizeof(struct hlist_head), GFP_ATOMIC); | 1106 | tbl_path->known_gates = kzalloc(sizeof(struct hlist_head), GFP_ATOMIC); |
1107 | if (!tbl_path->known_gates) { | ||
1108 | ret = -ENOMEM; | ||
1109 | goto free_path; | ||
1110 | } | ||
1106 | INIT_HLIST_HEAD(tbl_path->known_gates); | 1111 | INIT_HLIST_HEAD(tbl_path->known_gates); |
1107 | 1112 | ||
1108 | 1113 | ||
1109 | tbl_mpp = mesh_table_alloc(INIT_PATHS_SIZE_ORDER); | 1114 | tbl_mpp = mesh_table_alloc(INIT_PATHS_SIZE_ORDER); |
1110 | if (!tbl_mpp) { | 1115 | if (!tbl_mpp) { |
1111 | mesh_table_free(tbl_path, true); | 1116 | ret = -ENOMEM; |
1112 | return -ENOMEM; | 1117 | goto free_path; |
1113 | } | 1118 | } |
1114 | tbl_mpp->free_node = &mesh_path_node_free; | 1119 | tbl_mpp->free_node = &mesh_path_node_free; |
1115 | tbl_mpp->copy_node = &mesh_path_node_copy; | 1120 | tbl_mpp->copy_node = &mesh_path_node_copy; |
1116 | tbl_mpp->mean_chain_len = MEAN_CHAIN_LEN; | 1121 | tbl_mpp->mean_chain_len = MEAN_CHAIN_LEN; |
1117 | tbl_mpp->known_gates = kzalloc(sizeof(struct hlist_head), GFP_ATOMIC); | 1122 | tbl_mpp->known_gates = kzalloc(sizeof(struct hlist_head), GFP_ATOMIC); |
1123 | if (!tbl_mpp->known_gates) { | ||
1124 | ret = -ENOMEM; | ||
1125 | goto free_mpp; | ||
1126 | } | ||
1118 | INIT_HLIST_HEAD(tbl_mpp->known_gates); | 1127 | INIT_HLIST_HEAD(tbl_mpp->known_gates); |
1119 | 1128 | ||
1120 | /* Need no locking since this is during init */ | 1129 | /* Need no locking since this is during init */ |
@@ -1122,6 +1131,12 @@ int mesh_pathtbl_init(void) | |||
1122 | RCU_INIT_POINTER(mpp_paths, tbl_mpp); | 1131 | RCU_INIT_POINTER(mpp_paths, tbl_mpp); |
1123 | 1132 | ||
1124 | return 0; | 1133 | return 0; |
1134 | |||
1135 | free_mpp: | ||
1136 | mesh_table_free(tbl_mpp, true); | ||
1137 | free_path: | ||
1138 | mesh_table_free(tbl_path, true); | ||
1139 | return ret; | ||
1125 | } | 1140 | } |
1126 | 1141 | ||
1127 | void mesh_path_expire(struct ieee80211_sub_if_data *sdata) | 1142 | void mesh_path_expire(struct ieee80211_sub_if_data *sdata) |