diff options
Diffstat (limited to 'net/tipc/cluster.c')
| -rw-r--r-- | net/tipc/cluster.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/net/tipc/cluster.c b/net/tipc/cluster.c index 1aed81584e96..b46b5188a9fd 100644 --- a/net/tipc/cluster.c +++ b/net/tipc/cluster.c | |||
| @@ -57,43 +57,43 @@ 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) { |
| 63 | warn("Cluster creation failure, no memory\n"); | ||
| 64 | return NULL; | 64 | return NULL; |
| 65 | memset(c_ptr, 0, sizeof(*c_ptr)); | 65 | } |
| 66 | 66 | ||
| 67 | 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); |
| 68 | if (in_own_cluster(addr)) | 68 | if (in_own_cluster(addr)) |
| 69 | max_nodes = LOWEST_SLAVE + tipc_max_slaves; | 69 | max_nodes = LOWEST_SLAVE + tipc_max_slaves; |
| 70 | else | 70 | else |
| 71 | max_nodes = tipc_max_nodes + 1; | 71 | max_nodes = tipc_max_nodes + 1; |
| 72 | alloc = sizeof(void *) * (max_nodes + 1); | 72 | |
| 73 | c_ptr->nodes = (struct node **)kmalloc(alloc, GFP_ATOMIC); | 73 | c_ptr->nodes = kcalloc(max_nodes + 1, sizeof(void*), GFP_ATOMIC); |
| 74 | if (c_ptr->nodes == NULL) { | 74 | if (c_ptr->nodes == NULL) { |
| 75 | warn("Cluster creation failure, no memory for node area\n"); | ||
| 75 | kfree(c_ptr); | 76 | kfree(c_ptr); |
| 76 | return NULL; | 77 | return NULL; |
| 77 | } | 78 | } |
| 78 | memset(c_ptr->nodes, 0, alloc); | 79 | |
| 79 | if (in_own_cluster(addr)) | 80 | if (in_own_cluster(addr)) |
| 80 | tipc_local_nodes = c_ptr->nodes; | 81 | tipc_local_nodes = c_ptr->nodes; |
| 81 | c_ptr->highest_slave = LOWEST_SLAVE - 1; | 82 | c_ptr->highest_slave = LOWEST_SLAVE - 1; |
| 82 | c_ptr->highest_node = 0; | 83 | c_ptr->highest_node = 0; |
| 83 | 84 | ||
| 84 | z_ptr = tipc_zone_find(tipc_zone(addr)); | 85 | z_ptr = tipc_zone_find(tipc_zone(addr)); |
| 85 | if (z_ptr == NULL) { | 86 | if (!z_ptr) { |
| 86 | z_ptr = tipc_zone_create(addr); | 87 | z_ptr = tipc_zone_create(addr); |
| 87 | } | 88 | } |
| 88 | if (z_ptr != NULL) { | 89 | if (!z_ptr) { |
| 89 | tipc_zone_attach_cluster(z_ptr, c_ptr); | 90 | kfree(c_ptr->nodes); |
| 90 | c_ptr->owner = z_ptr; | ||
| 91 | } | ||
| 92 | else { | ||
| 93 | kfree(c_ptr); | 91 | kfree(c_ptr); |
| 94 | c_ptr = NULL; | 92 | return NULL; |
| 95 | } | 93 | } |
| 96 | 94 | ||
| 95 | tipc_zone_attach_cluster(z_ptr, c_ptr); | ||
| 96 | c_ptr->owner = z_ptr; | ||
| 97 | return c_ptr; | 97 | return c_ptr; |
| 98 | } | 98 | } |
| 99 | 99 | ||
