From patchwork Thu Aug 26 09:12:38 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 133941 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o7Q9D9A1026983 for ; Thu, 26 Aug 2010 09:13:09 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753498Ab0HZJNI (ORCPT ); Thu, 26 Aug 2010 05:13:08 -0400 Received: from mail-qw0-f46.google.com ([209.85.216.46]:65119 "EHLO mail-qw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753441Ab0HZJNH (ORCPT ); Thu, 26 Aug 2010 05:13:07 -0400 Received: by qwh6 with SMTP id 6so1390573qwh.19 for ; Thu, 26 Aug 2010 02:13:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:mime-version:content-type:content-disposition:user-agent; bh=SGWxjvoljOGOU5rPlAhbdMiiXHJ4uTsOnbF/KCqNKb8=; b=YSCopFVsW19ahuAxJwaGKo6onSDsvGmf7pdyKCTRtFcVzXf5BJvgWb4ZdFxGT+uvcM BwzRb+C8ou2xE6U5HG3f2FWM5rpQMUeTXL3lI97vrS8N7xyanvCfMTEO5NOSlExhMoop yhmYgpc80zgDWYs2wM0Rkd1Xx94B50orqpVaM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; b=YQQAXfHSx8u5Pic5TIewW5c29QayJOot1kFlVKX47bHW4LO6O2CecvGEIx2yyqaaqq uYDaas3e7QZl5H1HqTcYRxQTwlP1xVEiGCpwNqv6eVpxqSc9iKZIDS7huRW+T/cNi/vA JT5saxfgpBpexWnQDHLHaWwo7ub9nUGTKAWSA= Received: by 10.224.57.213 with SMTP id d21mr6468790qah.136.1282813986676; Thu, 26 Aug 2010 02:13:06 -0700 (PDT) Received: from bicker ([41.205.146.22]) by mx.google.com with ESMTPS id e6sm2774199qcr.29.2010.08.26.02.12.55 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 26 Aug 2010 02:13:05 -0700 (PDT) Date: Thu, 26 Aug 2010 11:12:38 +0200 From: Dan Carpenter To: Sage Weil Cc: Yehuda Sadeh , ceph-devel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [patch] ceph: fix get_ticket_handler() error handling Message-ID: <20100826091238.GB20072@bicker> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Thu, 26 Aug 2010 09:13:09 +0000 (UTC) diff --git a/fs/ceph/auth_x.c b/fs/ceph/auth_x.c index 582e0b2..a2d002c 100644 --- a/fs/ceph/auth_x.c +++ b/fs/ceph/auth_x.c @@ -376,7 +376,7 @@ static void ceph_x_validate_tickets(struct ceph_auth_client *ac, int *pneed) th = get_ticket_handler(ac, service); - if (!th) { + if (IS_ERR(th)) { *pneed |= service; continue; } @@ -399,6 +399,9 @@ static int ceph_x_build_request(struct ceph_auth_client *ac, struct ceph_x_ticket_handler *th = get_ticket_handler(ac, CEPH_ENTITY_TYPE_AUTH); + if (IS_ERR(th)) + return PTR_ERR(th); + ceph_x_validate_tickets(ac, &need); 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, return -ERANGE; head->op = cpu_to_le16(CEPHX_GET_PRINCIPAL_SESSION_KEY); - BUG_ON(!th); ret = ceph_x_build_authorizer(ac, th, &xi->auth_authorizer); if (ret) return ret; @@ -505,7 +507,8 @@ static int ceph_x_handle_reply(struct ceph_auth_client *ac, int result, case CEPHX_GET_PRINCIPAL_SESSION_KEY: 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, buf + sizeof(*head), end); break; @@ -563,8 +566,8 @@ static int ceph_x_verify_authorizer_reply(struct ceph_auth_client *ac, void *end = p + sizeof(au->reply_buf); th = get_ticket_handler(ac, au->service); - if (!th) - return -EIO; /* hrm! */ + if (IS_ERR(th)) + return PTR_ERR(th); ret = ceph_x_decrypt(&th->session_key, &p, end, &reply, sizeof(reply)); if (ret < 0) return ret; @@ -626,7 +629,7 @@ static void ceph_x_invalidate_authorizer(struct ceph_auth_client *ac, struct ceph_x_ticket_handler *th; th = get_ticket_handler(ac, peer_type); - if (th && !IS_ERR(th)) + if (!IS_ERR(th)) remove_ticket_handler(ac, th); }