diff options
Diffstat (limited to 'net/tipc/cluster.c')
| -rw-r--r-- | net/tipc/cluster.c | 8 |
1 files changed, 2 insertions, 6 deletions
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; |
