staging: lustre: lnet: keep ln_nportals consistent
ln_nportals should be zero when no portals have been allocated. This ensures that memory allocation failure is handled correctly elsewhere. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
3ab19e61b3
commit
2e20a07f3b
@ -841,6 +841,7 @@ lnet_portals_destroy(void)
|
|||||||
|
|
||||||
cfs_array_free(the_lnet.ln_portals);
|
cfs_array_free(the_lnet.ln_portals);
|
||||||
the_lnet.ln_portals = NULL;
|
the_lnet.ln_portals = NULL;
|
||||||
|
the_lnet.ln_nportals = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -851,12 +852,12 @@ lnet_portals_create(void)
|
|||||||
|
|
||||||
size = offsetof(struct lnet_portal, ptl_mt_maps[LNET_CPT_NUMBER]);
|
size = offsetof(struct lnet_portal, ptl_mt_maps[LNET_CPT_NUMBER]);
|
||||||
|
|
||||||
the_lnet.ln_nportals = MAX_PORTALS;
|
the_lnet.ln_portals = cfs_array_alloc(MAX_PORTALS, size);
|
||||||
the_lnet.ln_portals = cfs_array_alloc(the_lnet.ln_nportals, size);
|
|
||||||
if (!the_lnet.ln_portals) {
|
if (!the_lnet.ln_portals) {
|
||||||
CERROR("Failed to allocate portals table\n");
|
CERROR("Failed to allocate portals table\n");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
the_lnet.ln_nportals = MAX_PORTALS;
|
||||||
|
|
||||||
for (i = 0; i < the_lnet.ln_nportals; i++) {
|
for (i = 0; i < the_lnet.ln_nportals; i++) {
|
||||||
if (lnet_ptl_setup(the_lnet.ln_portals[i], i)) {
|
if (lnet_ptl_setup(the_lnet.ln_portals[i], i)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user