diff options
Diffstat (limited to 'net/tipc')
-rw-r--r-- | net/tipc/bearer.c | 6 | ||||
-rw-r--r-- | net/tipc/cluster.c | 8 | ||||
-rw-r--r-- | net/tipc/link.c | 3 | ||||
-rw-r--r-- | net/tipc/name_table.c | 16 | ||||
-rw-r--r-- | net/tipc/net.c | 5 | ||||
-rw-r--r-- | net/tipc/port.c | 5 | ||||
-rw-r--r-- | net/tipc/subscr.c | 3 | ||||
-rw-r--r-- | net/tipc/user_reg.c | 3 | ||||
-rw-r--r-- | net/tipc/zone.c | 3 |
9 files changed, 15 insertions, 37 deletions
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c index 7ef17a449cfd..75a5968c2139 100644 --- a/net/tipc/bearer.c +++ b/net/tipc/bearer.c | |||
@@ -665,11 +665,9 @@ int tipc_bearer_init(void) | |||
665 | int res; | 665 | int res; |
666 | 666 | ||
667 | write_lock_bh(&tipc_net_lock); | 667 | write_lock_bh(&tipc_net_lock); |
668 | tipc_bearers = kmalloc(MAX_BEARERS * sizeof(struct bearer), GFP_ATOMIC); | 668 | tipc_bearers = kcalloc(MAX_BEARERS, sizeof(struct bearer), GFP_ATOMIC); |
669 | media_list = kmalloc(MAX_MEDIA * sizeof(struct media), GFP_ATOMIC); | 669 | media_list = kcalloc(MAX_MEDIA, sizeof(struct media), GFP_ATOMIC); |
670 | if (tipc_bearers && media_list) { | 670 | if (tipc_bearers && media_list) { |
671 | memset(tipc_bearers, 0, MAX_BEARERS * sizeof(struct bearer)); | ||
672 | memset(media_list, 0, MAX_MEDIA * sizeof(struct media)); | ||
673 | res = TIPC_OK; | 671 | res = TIPC_OK; |
674 | } else { | 672 | } else { |
675 | kfree(tipc_bearers); | 673 | kfree(tipc_bearers); |
diff --git a/net/tipc/cluster.c b/net/tipc/cluster.c index 1dcb6940e338..b46b5188a9fd 100644 --- a/net/tipc/cluster.c +++ b/net/tipc/cluster.c | |||
@@ -57,29 +57,25 @@ struct cluster *tipc_cltr_create(u32 addr) | |||
57 | struct _zone *z_ptr; | 57 | struct _zone *z_ptr; |
58 | struct cluster *c_ptr; | 58 | struct cluster *c_ptr; |
59 | int max_nodes; | 59 | int max_nodes; |
60 | int alloc; | ||
61 | 60 | ||
62 | c_ptr = (struct cluster *)kmalloc(sizeof(*c_ptr), GFP_ATOMIC); | 61 | c_ptr = kzalloc(sizeof(*c_ptr), GFP_ATOMIC); |
63 | if (c_ptr == NULL) { | 62 | if (c_ptr == NULL) { |
64 | warn("Cluster creation failure, no memory\n"); | 63 | warn("Cluster creation failure, no memory\n"); |
65 | return NULL; | 64 | return NULL; |
66 | } | 65 | } |
67 | memset(c_ptr, 0, sizeof(*c_ptr)); | ||
68 | 66 | ||
69 | c_ptr->addr = tipc_addr(tipc_zone(addr), tipc_cluster(addr), 0); | 67 | c_ptr->addr = tipc_addr(tipc_zone(addr), tipc_cluster(addr), 0); |
70 | if (in_own_cluster(addr)) | 68 | if (in_own_cluster(addr)) |
71 | max_nodes = LOWEST_SLAVE + tipc_max_slaves; | 69 | max_nodes = LOWEST_SLAVE + tipc_max_slaves; |
72 | else | 70 | else |
73 | max_nodes = tipc_max_nodes + 1; | 71 | max_nodes = tipc_max_nodes + 1; |
74 | alloc = sizeof(void *) * (max_nodes + 1); | ||
75 | 72 | ||
76 | c_ptr->nodes = (struct node **)kmalloc(alloc, GFP_ATOMIC); | 73 | c_ptr->nodes = kcalloc(max_nodes + 1, sizeof(void*), GFP_ATOMIC); |
77 | if (c_ptr->nodes == NULL) { | 74 | if (c_ptr->nodes == NULL) { |
78 | warn("Cluster creation failure, no memory for node area\n"); | 75 | warn("Cluster creation failure, no memory for node area\n"); |
79 | kfree(c_ptr); | 76 | kfree(c_ptr); |
80 | return NULL; | 77 | return NULL; |
81 | } | 78 | } |
82 | memset(c_ptr->nodes, 0, alloc); | ||
83 | 79 | ||
84 | if (in_own_cluster(addr)) | 80 | if (in_own_cluster(addr)) |
85 | tipc_local_nodes = c_ptr->nodes; | 81 | tipc_local_nodes = c_ptr->nodes; |
diff --git a/net/tipc/link.c b/net/tipc/link.c index c10e18a49b96..693f02eca6d6 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c | |||
@@ -417,12 +417,11 @@ struct link *tipc_link_create(struct bearer *b_ptr, const u32 peer, | |||
417 | struct tipc_msg *msg; | 417 | struct tipc_msg *msg; |
418 | char *if_name; | 418 | char *if_name; |
419 | 419 | ||
420 | l_ptr = (struct link *)kmalloc(sizeof(*l_ptr), GFP_ATOMIC); | 420 | l_ptr = kzalloc(sizeof(*l_ptr), GFP_ATOMIC); |
421 | if (!l_ptr) { | 421 | if (!l_ptr) { |
422 | warn("Link creation failed, no memory\n"); | 422 | warn("Link creation failed, no memory\n"); |
423 | return NULL; | 423 | return NULL; |
424 | } | 424 | } |
425 | memset(l_ptr, 0, sizeof(*l_ptr)); | ||
426 | 425 | ||
427 | l_ptr->addr = peer; | 426 | l_ptr->addr = peer; |
428 | if_name = strchr(b_ptr->publ.name, ':') + 1; | 427 | if_name = strchr(b_ptr->publ.name, ':') + 1; |
diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c index a6926ff07bcc..049242ea5c38 100644 --- a/net/tipc/name_table.c +++ b/net/tipc/name_table.c | |||
@@ -117,14 +117,12 @@ static struct publication *publ_create(u32 type, u32 lower, u32 upper, | |||
117 | u32 scope, u32 node, u32 port_ref, | 117 | u32 scope, u32 node, u32 port_ref, |
118 | u32 key) | 118 | u32 key) |
119 | { | 119 | { |
120 | struct publication *publ = | 120 | struct publication *publ = kzalloc(sizeof(*publ), GFP_ATOMIC); |
121 | (struct publication *)kmalloc(sizeof(*publ), GFP_ATOMIC); | ||
122 | if (publ == NULL) { | 121 | if (publ == NULL) { |
123 | warn("Publication creation failure, no memory\n"); | 122 | warn("Publication creation failure, no memory\n"); |
124 | return NULL; | 123 | return NULL; |
125 | } | 124 | } |
126 | 125 | ||
127 | memset(publ, 0, sizeof(*publ)); | ||
128 | publ->type = type; | 126 | publ->type = type; |
129 | publ->lower = lower; | 127 | publ->lower = lower; |
130 | publ->upper = upper; | 128 | publ->upper = upper; |
@@ -144,11 +142,7 @@ static struct publication *publ_create(u32 type, u32 lower, u32 upper, | |||
144 | 142 | ||
145 | static struct sub_seq *tipc_subseq_alloc(u32 cnt) | 143 | static struct sub_seq *tipc_subseq_alloc(u32 cnt) |
146 | { | 144 | { |
147 | u32 sz = cnt * sizeof(struct sub_seq); | 145 | struct sub_seq *sseq = kcalloc(cnt, sizeof(struct sub_seq), GFP_ATOMIC); |
148 | struct sub_seq *sseq = (struct sub_seq *)kmalloc(sz, GFP_ATOMIC); | ||
149 | |||
150 | if (sseq) | ||
151 | memset(sseq, 0, sz); | ||
152 | return sseq; | 146 | return sseq; |
153 | } | 147 | } |
154 | 148 | ||
@@ -160,8 +154,7 @@ static struct sub_seq *tipc_subseq_alloc(u32 cnt) | |||
160 | 154 | ||
161 | static struct name_seq *tipc_nameseq_create(u32 type, struct hlist_head *seq_head) | 155 | static struct name_seq *tipc_nameseq_create(u32 type, struct hlist_head *seq_head) |
162 | { | 156 | { |
163 | struct name_seq *nseq = | 157 | struct name_seq *nseq = kzalloc(sizeof(*nseq), GFP_ATOMIC); |
164 | (struct name_seq *)kmalloc(sizeof(*nseq), GFP_ATOMIC); | ||
165 | struct sub_seq *sseq = tipc_subseq_alloc(1); | 158 | struct sub_seq *sseq = tipc_subseq_alloc(1); |
166 | 159 | ||
167 | if (!nseq || !sseq) { | 160 | if (!nseq || !sseq) { |
@@ -171,7 +164,6 @@ static struct name_seq *tipc_nameseq_create(u32 type, struct hlist_head *seq_hea | |||
171 | return NULL; | 164 | return NULL; |
172 | } | 165 | } |
173 | 166 | ||
174 | memset(nseq, 0, sizeof(*nseq)); | ||
175 | spin_lock_init(&nseq->lock); | 167 | spin_lock_init(&nseq->lock); |
176 | nseq->type = type; | 168 | nseq->type = type; |
177 | nseq->sseqs = sseq; | 169 | nseq->sseqs = sseq; |
@@ -1060,7 +1052,7 @@ int tipc_nametbl_init(void) | |||
1060 | { | 1052 | { |
1061 | int array_size = sizeof(struct hlist_head) * tipc_nametbl_size; | 1053 | int array_size = sizeof(struct hlist_head) * tipc_nametbl_size; |
1062 | 1054 | ||
1063 | table.types = (struct hlist_head *)kmalloc(array_size, GFP_ATOMIC); | 1055 | table.types = kmalloc(array_size, GFP_ATOMIC); |
1064 | if (!table.types) | 1056 | if (!table.types) |
1065 | return -ENOMEM; | 1057 | return -ENOMEM; |
1066 | 1058 | ||
diff --git a/net/tipc/net.c b/net/tipc/net.c index e5a359ab4930..a991bf8a7f74 100644 --- a/net/tipc/net.c +++ b/net/tipc/net.c | |||
@@ -160,14 +160,11 @@ void tipc_net_send_external_routes(u32 dest) | |||
160 | 160 | ||
161 | static int net_init(void) | 161 | static int net_init(void) |
162 | { | 162 | { |
163 | u32 sz = sizeof(struct _zone *) * (tipc_max_zones + 1); | ||
164 | |||
165 | memset(&tipc_net, 0, sizeof(tipc_net)); | 163 | memset(&tipc_net, 0, sizeof(tipc_net)); |
166 | tipc_net.zones = (struct _zone **)kmalloc(sz, GFP_ATOMIC); | 164 | tipc_net.zones = kcalloc(tipc_max_zones + 1, sizeof(struct _zone *), GFP_ATOMIC); |
167 | if (!tipc_net.zones) { | 165 | if (!tipc_net.zones) { |
168 | return -ENOMEM; | 166 | return -ENOMEM; |
169 | } | 167 | } |
170 | memset(tipc_net.zones, 0, sz); | ||
171 | return TIPC_OK; | 168 | return TIPC_OK; |
172 | } | 169 | } |
173 | 170 | ||
diff --git a/net/tipc/port.c b/net/tipc/port.c index 3251c8d8e53c..b9c8c6b9e94f 100644 --- a/net/tipc/port.c +++ b/net/tipc/port.c | |||
@@ -226,12 +226,11 @@ u32 tipc_createport_raw(void *usr_handle, | |||
226 | struct tipc_msg *msg; | 226 | struct tipc_msg *msg; |
227 | u32 ref; | 227 | u32 ref; |
228 | 228 | ||
229 | p_ptr = kmalloc(sizeof(*p_ptr), GFP_ATOMIC); | 229 | p_ptr = kzalloc(sizeof(*p_ptr), GFP_ATOMIC); |
230 | if (!p_ptr) { | 230 | if (!p_ptr) { |
231 | warn("Port creation failed, no memory\n"); | 231 | warn("Port creation failed, no memory\n"); |
232 | return 0; | 232 | return 0; |
233 | } | 233 | } |
234 | memset(p_ptr, 0, sizeof(*p_ptr)); | ||
235 | ref = tipc_ref_acquire(p_ptr, &p_ptr->publ.lock); | 234 | ref = tipc_ref_acquire(p_ptr, &p_ptr->publ.lock); |
236 | if (!ref) { | 235 | if (!ref) { |
237 | warn("Port creation failed, reference table exhausted\n"); | 236 | warn("Port creation failed, reference table exhausted\n"); |
@@ -1058,7 +1057,7 @@ int tipc_createport(u32 user_ref, | |||
1058 | struct port *p_ptr; | 1057 | struct port *p_ptr; |
1059 | u32 ref; | 1058 | u32 ref; |
1060 | 1059 | ||
1061 | up_ptr = (struct user_port *)kmalloc(sizeof(*up_ptr), GFP_ATOMIC); | 1060 | up_ptr = kmalloc(sizeof(*up_ptr), GFP_ATOMIC); |
1062 | if (!up_ptr) { | 1061 | if (!up_ptr) { |
1063 | warn("Port creation failed, no memory\n"); | 1062 | warn("Port creation failed, no memory\n"); |
1064 | return -ENOMEM; | 1063 | return -ENOMEM; |
diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c index e19b4bcd67ec..c51600ba5f4a 100644 --- a/net/tipc/subscr.c +++ b/net/tipc/subscr.c | |||
@@ -393,12 +393,11 @@ static void subscr_named_msg_event(void *usr_handle, | |||
393 | 393 | ||
394 | /* Create subscriber object */ | 394 | /* Create subscriber object */ |
395 | 395 | ||
396 | subscriber = kmalloc(sizeof(struct subscriber), GFP_ATOMIC); | 396 | subscriber = kzalloc(sizeof(struct subscriber), GFP_ATOMIC); |
397 | if (subscriber == NULL) { | 397 | if (subscriber == NULL) { |
398 | warn("Subscriber rejected, no memory\n"); | 398 | warn("Subscriber rejected, no memory\n"); |
399 | return; | 399 | return; |
400 | } | 400 | } |
401 | memset(subscriber, 0, sizeof(struct subscriber)); | ||
402 | INIT_LIST_HEAD(&subscriber->subscription_list); | 401 | INIT_LIST_HEAD(&subscriber->subscription_list); |
403 | INIT_LIST_HEAD(&subscriber->subscriber_list); | 402 | INIT_LIST_HEAD(&subscriber->subscriber_list); |
404 | subscriber->ref = tipc_ref_acquire(subscriber, &subscriber->lock); | 403 | subscriber->ref = tipc_ref_acquire(subscriber, &subscriber->lock); |
diff --git a/net/tipc/user_reg.c b/net/tipc/user_reg.c index 1e3ae57c7228..04d1b9be9c51 100644 --- a/net/tipc/user_reg.c +++ b/net/tipc/user_reg.c | |||
@@ -82,9 +82,8 @@ static int reg_init(void) | |||
82 | 82 | ||
83 | spin_lock_bh(®_lock); | 83 | spin_lock_bh(®_lock); |
84 | if (!users) { | 84 | if (!users) { |
85 | users = (struct tipc_user *)kmalloc(USER_LIST_SIZE, GFP_ATOMIC); | 85 | users = kzalloc(USER_LIST_SIZE, GFP_ATOMIC); |
86 | if (users) { | 86 | if (users) { |
87 | memset(users, 0, USER_LIST_SIZE); | ||
88 | for (i = 1; i <= MAX_USERID; i++) { | 87 | for (i = 1; i <= MAX_USERID; i++) { |
89 | users[i].next = i - 1; | 88 | users[i].next = i - 1; |
90 | } | 89 | } |
diff --git a/net/tipc/zone.c b/net/tipc/zone.c index 316c4872ff5b..f5b00ea2d5ac 100644 --- a/net/tipc/zone.c +++ b/net/tipc/zone.c | |||
@@ -52,13 +52,12 @@ struct _zone *tipc_zone_create(u32 addr) | |||
52 | return NULL; | 52 | return NULL; |
53 | } | 53 | } |
54 | 54 | ||
55 | z_ptr = (struct _zone *)kmalloc(sizeof(*z_ptr), GFP_ATOMIC); | 55 | z_ptr = kzalloc(sizeof(*z_ptr), GFP_ATOMIC); |
56 | if (!z_ptr) { | 56 | if (!z_ptr) { |
57 | warn("Zone creation failed, insufficient memory\n"); | 57 | warn("Zone creation failed, insufficient memory\n"); |
58 | return NULL; | 58 | return NULL; |
59 | } | 59 | } |
60 | 60 | ||
61 | memset(z_ptr, 0, sizeof(*z_ptr)); | ||
62 | z_num = tipc_zone(addr); | 61 | z_num = tipc_zone(addr); |
63 | z_ptr->addr = tipc_addr(z_num, 0, 0); | 62 | z_ptr->addr = tipc_addr(z_num, 0, 0); |
64 | tipc_net.zones[z_num] = z_ptr; | 63 | tipc_net.zones[z_num] = z_ptr; |