Commit b545787d authored by Dan Carpenter's avatar Dan Carpenter Committed by Sage Weil

ceph: fix get_ticket_handler() error handling

get_ticket_handler() returns a valid pointer or it returns
ERR_PTR(-ENOMEM) if kzalloc() fails.
Signed-off-by: default avatarDan Carpenter <error27@gmail.com>
Signed-off-by: default avatarSage Weil <sage@newdream.net>
parent e072f8aa
...@@ -376,7 +376,7 @@ static void ceph_x_validate_tickets(struct ceph_auth_client *ac, int *pneed) ...@@ -376,7 +376,7 @@ static void ceph_x_validate_tickets(struct ceph_auth_client *ac, int *pneed)
th = get_ticket_handler(ac, service); th = get_ticket_handler(ac, service);
if (!th) { if (IS_ERR(th)) {
*pneed |= service; *pneed |= service;
continue; continue;
} }
...@@ -399,6 +399,9 @@ static int ceph_x_build_request(struct ceph_auth_client *ac, ...@@ -399,6 +399,9 @@ static int ceph_x_build_request(struct ceph_auth_client *ac,
struct ceph_x_ticket_handler *th = struct ceph_x_ticket_handler *th =
get_ticket_handler(ac, CEPH_ENTITY_TYPE_AUTH); get_ticket_handler(ac, CEPH_ENTITY_TYPE_AUTH);
if (IS_ERR(th))
return PTR_ERR(th);
ceph_x_validate_tickets(ac, &need); ceph_x_validate_tickets(ac, &need);
dout("build_request want %x have %x need %x\n", dout("build_request want %x have %x need %x\n",
...@@ -450,7 +453,6 @@ static int ceph_x_build_request(struct ceph_auth_client *ac, ...@@ -450,7 +453,6 @@ static int ceph_x_build_request(struct ceph_auth_client *ac,
return -ERANGE; return -ERANGE;
head->op = cpu_to_le16(CEPHX_GET_PRINCIPAL_SESSION_KEY); head->op = cpu_to_le16(CEPHX_GET_PRINCIPAL_SESSION_KEY);
BUG_ON(!th);
ret = ceph_x_build_authorizer(ac, th, &xi->auth_authorizer); ret = ceph_x_build_authorizer(ac, th, &xi->auth_authorizer);
if (ret) if (ret)
return ret; return ret;
...@@ -505,7 +507,8 @@ static int ceph_x_handle_reply(struct ceph_auth_client *ac, int result, ...@@ -505,7 +507,8 @@ static int ceph_x_handle_reply(struct ceph_auth_client *ac, int result,
case CEPHX_GET_PRINCIPAL_SESSION_KEY: case CEPHX_GET_PRINCIPAL_SESSION_KEY:
th = get_ticket_handler(ac, CEPH_ENTITY_TYPE_AUTH); th = get_ticket_handler(ac, CEPH_ENTITY_TYPE_AUTH);
BUG_ON(!th); if (IS_ERR(th))
return PTR_ERR(th);
ret = ceph_x_proc_ticket_reply(ac, &th->session_key, ret = ceph_x_proc_ticket_reply(ac, &th->session_key,
buf + sizeof(*head), end); buf + sizeof(*head), end);
break; break;
...@@ -563,8 +566,8 @@ static int ceph_x_verify_authorizer_reply(struct ceph_auth_client *ac, ...@@ -563,8 +566,8 @@ static int ceph_x_verify_authorizer_reply(struct ceph_auth_client *ac,
void *end = p + sizeof(au->reply_buf); void *end = p + sizeof(au->reply_buf);
th = get_ticket_handler(ac, au->service); th = get_ticket_handler(ac, au->service);
if (!th) if (IS_ERR(th))
return -EIO; /* hrm! */ return PTR_ERR(th);
ret = ceph_x_decrypt(&th->session_key, &p, end, &reply, sizeof(reply)); ret = ceph_x_decrypt(&th->session_key, &p, end, &reply, sizeof(reply));
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -626,7 +629,7 @@ static void ceph_x_invalidate_authorizer(struct ceph_auth_client *ac, ...@@ -626,7 +629,7 @@ static void ceph_x_invalidate_authorizer(struct ceph_auth_client *ac,
struct ceph_x_ticket_handler *th; struct ceph_x_ticket_handler *th;
th = get_ticket_handler(ac, peer_type); th = get_ticket_handler(ac, peer_type);
if (th && !IS_ERR(th)) if (!IS_ERR(th))
remove_ticket_handler(ac, th); remove_ticket_handler(ac, th);
} }
......
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