Skip to content

Commit 49d9224

Browse files
dotnwatliewegas
authored andcommitted
ceph: fix ceph_monc_init memory leak
failure clean up does not consider ceph_auth_init. Signed-off-by: Noah Watkins <noahwatkins@gmail.com> Signed-off-by: Sage Weil <sage@newdream.net>
1 parent a35eca9 commit 49d9224

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

‎net/ceph/mon_client.c‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -759,8 +759,10 @@ int ceph_monc_init(struct ceph_mon_client *monc, struct ceph_client *cl)
759759
/* authentication */
760760
monc->auth = ceph_auth_init(cl->options->name,
761761
cl->options->key);
762-
if (IS_ERR(monc->auth))
763-
return PTR_ERR(monc->auth);
762+
if (IS_ERR(monc->auth)) {
763+
err = PTR_ERR(monc->auth);
764+
goto out_con;
765+
}
764766
monc->auth->want_keys =
765767
CEPH_ENTITY_TYPE_AUTH | CEPH_ENTITY_TYPE_MON |
766768
CEPH_ENTITY_TYPE_OSD | CEPH_ENTITY_TYPE_MDS;
@@ -771,7 +773,7 @@ int ceph_monc_init(struct ceph_mon_client *monc, struct ceph_client *cl)
771773
sizeof(struct ceph_mon_subscribe_ack),
772774
GFP_NOFS, true);
773775
if (!monc->m_subscribe_ack)
774-
goto out_con;
776+
goto out_auth;
775777

776778
monc->m_subscribe = ceph_msg_new(CEPH_MSG_MON_SUBSCRIBE, 96, GFP_NOFS,
777779
true);
@@ -809,6 +811,8 @@ int ceph_monc_init(struct ceph_mon_client *monc, struct ceph_client *cl)
809811
ceph_msg_put(monc->m_subscribe);
810812
out_subscribe_ack:
811813
ceph_msg_put(monc->m_subscribe_ack);
814+
out_auth:
815+
ceph_auth_destroy(monc->auth);
812816
out_con:
813817
monc->con->ops->put(monc->con);
814818
out_monmap:

0 commit comments

Comments
 (0)