Commit 4a4e07c1 authored by Joseph Qi's avatar Joseph Qi Committed by Linus Torvalds

ocfs2: call o2quo_exit() if malloc failed in o2net_init()

In o2net_init, if malloc failed, it directly returns -ENOMEM.  Then
o2quo_exit won't be called in init_o2nm.
Signed-off-by: default avatarJoseph Qi <joseph.qi@huawei.com>
Reviewed-by: default avatarjoyce.xue <xuejiufei@huawei.com>
Cc: Mark Fasheh <mfasheh@suse.com>
Cc: Joel Becker <jlbec@evilplan.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 7fa05c6e
...@@ -2146,17 +2146,13 @@ int o2net_init(void) ...@@ -2146,17 +2146,13 @@ int o2net_init(void)
o2quo_init(); o2quo_init();
if (o2net_debugfs_init()) if (o2net_debugfs_init())
return -ENOMEM; goto out;
o2net_hand = kzalloc(sizeof(struct o2net_handshake), GFP_KERNEL); o2net_hand = kzalloc(sizeof(struct o2net_handshake), GFP_KERNEL);
o2net_keep_req = kzalloc(sizeof(struct o2net_msg), GFP_KERNEL); o2net_keep_req = kzalloc(sizeof(struct o2net_msg), GFP_KERNEL);
o2net_keep_resp = kzalloc(sizeof(struct o2net_msg), GFP_KERNEL); o2net_keep_resp = kzalloc(sizeof(struct o2net_msg), GFP_KERNEL);
if (!o2net_hand || !o2net_keep_req || !o2net_keep_resp) { if (!o2net_hand || !o2net_keep_req || !o2net_keep_resp)
kfree(o2net_hand); goto out;
kfree(o2net_keep_req);
kfree(o2net_keep_resp);
return -ENOMEM;
}
o2net_hand->protocol_version = cpu_to_be64(O2NET_PROTOCOL_VERSION); o2net_hand->protocol_version = cpu_to_be64(O2NET_PROTOCOL_VERSION);
o2net_hand->connector_id = cpu_to_be64(1); o2net_hand->connector_id = cpu_to_be64(1);
...@@ -2181,6 +2177,14 @@ int o2net_init(void) ...@@ -2181,6 +2177,14 @@ int o2net_init(void)
} }
return 0; return 0;
out:
kfree(o2net_hand);
kfree(o2net_keep_req);
kfree(o2net_keep_resp);
o2quo_exit();
return -ENOMEM;
} }
void o2net_exit(void) void o2net_exit(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment