All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sage Weil <sage@newdream.net>
To: Dan Carpenter <error27@gmail.com>
Cc: Yehuda Sadeh <yehuda@hq.newdream.net>,
	ceph-devel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch] ceph: fix get_ticket_handler() error handling
Date: Thu, 26 Aug 2010 16:30:18 +0000	[thread overview]
Message-ID: <Pine.LNX.4.64.1008260930140.22216@cobra.newdream.net> (raw)
In-Reply-To: <20100826091238.GB20072@bicker>

Applied, thanks!
sage


On Thu, 26 Aug 2010, Dan Carpenter wrote:

> get_ticket_handler() returns a valid pointer or it returns
> ERR_PTR(-ENOMEM) if kzalloc() fails.
> 
> Signed-off-by: Dan Carpenter <error27@gmail.com>
> 
> 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);
>  }
>  
> --
> To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> 

WARNING: multiple messages have this Message-ID (diff)
From: Sage Weil <sage@newdream.net>
To: Dan Carpenter <error27@gmail.com>
Cc: Yehuda Sadeh <yehuda@hq.newdream.net>,
	ceph-devel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch] ceph: fix get_ticket_handler() error handling
Date: Thu, 26 Aug 2010 09:30:18 -0700 (PDT)	[thread overview]
Message-ID: <Pine.LNX.4.64.1008260930140.22216@cobra.newdream.net> (raw)
In-Reply-To: <20100826091238.GB20072@bicker>

Applied, thanks!
sage


On Thu, 26 Aug 2010, Dan Carpenter wrote:

> get_ticket_handler() returns a valid pointer or it returns
> ERR_PTR(-ENOMEM) if kzalloc() fails.
> 
> Signed-off-by: Dan Carpenter <error27@gmail.com>
> 
> 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);
>  }
>  
> --
> To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> 

  reply	other threads:[~2010-08-26 16:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-26  9:12 [patch] ceph: fix get_ticket_handler() error handling Dan Carpenter
2010-08-26  9:12 ` Dan Carpenter
2010-08-26 16:30 ` Sage Weil [this message]
2010-08-26 16:30   ` Sage Weil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.64.1008260930140.22216@cobra.newdream.net \
    --to=sage@newdream.net \
    --cc=ceph-devel@vger.kernel.org \
    --cc=error27@gmail.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=yehuda@hq.newdream.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.