diff mbox

libceph: kfree() in put_osd() shouldn't depend on authorizer

Message ID 1424266039-40851-1-git-send-email-idryomov@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ilya Dryomov Feb. 18, 2015, 1:27 p.m. UTC
a255651d4cad ("ceph: ensure auth ops are defined before use") made
kfree() in put_osd() conditional on the authorizer.  A mechanical
mistake most likely - fix it.

Cc: Alex Elder <elder@linaro.org>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
---
 net/ceph/osd_client.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Sage Weil Feb. 18, 2015, 3:18 p.m. UTC | #1
On Wed, 18 Feb 2015, Ilya Dryomov wrote:
> a255651d4cad ("ceph: ensure auth ops are defined before use") made
> kfree() in put_osd() conditional on the authorizer.  A mechanical
> mistake most likely - fix it.
> 
> Cc: Alex Elder <elder@linaro.org>
> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>

Reviewed-by: Sage Weil <sage@redhat.com>
> ---
>  net/ceph/osd_client.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
> index f693a2f8ac86..41a4abc7e98e 100644
> --- a/net/ceph/osd_client.c
> +++ b/net/ceph/osd_client.c
> @@ -1035,10 +1035,11 @@ static void put_osd(struct ceph_osd *osd)
>  {
>  	dout("put_osd %p %d -> %d\n", osd, atomic_read(&osd->o_ref),
>  	     atomic_read(&osd->o_ref) - 1);
> -	if (atomic_dec_and_test(&osd->o_ref) && osd->o_auth.authorizer) {
> +	if (atomic_dec_and_test(&osd->o_ref)) {
>  		struct ceph_auth_client *ac = osd->o_osdc->client->monc.auth;
>  
> -		ceph_auth_destroy_authorizer(ac, osd->o_auth.authorizer);
> +		if (osd->o_auth.authorizer)
> +			ceph_auth_destroy_authorizer(ac, osd->o_auth.authorizer);
>  		kfree(osd);
>  	}
>  }
> -- 
> 1.9.3
> 
> --
> 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
> 
> 
--
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
Alex Elder Feb. 18, 2015, 3:47 p.m. UTC | #2
On 02/18/2015 07:27 AM, Ilya Dryomov wrote:
> a255651d4cad ("ceph: ensure auth ops are defined before use") made
> kfree() in put_osd() conditional on the authorizer.  A mechanical
> mistake most likely - fix it.

You are generous in suggesting it's a mechanical mistake.
But it is a mistake nevertheless.  The fix looks good.

Reviewed-by: Alex Elder <elder@linaro.org>

> Cc: Alex Elder <elder@linaro.org>
> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
> ---
>  net/ceph/osd_client.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
> index f693a2f8ac86..41a4abc7e98e 100644
> --- a/net/ceph/osd_client.c
> +++ b/net/ceph/osd_client.c
> @@ -1035,10 +1035,11 @@ static void put_osd(struct ceph_osd *osd)
>  {
>  	dout("put_osd %p %d -> %d\n", osd, atomic_read(&osd->o_ref),
>  	     atomic_read(&osd->o_ref) - 1);
> -	if (atomic_dec_and_test(&osd->o_ref) && osd->o_auth.authorizer) {
> +	if (atomic_dec_and_test(&osd->o_ref)) {
>  		struct ceph_auth_client *ac = osd->o_osdc->client->monc.auth;
>  
> -		ceph_auth_destroy_authorizer(ac, osd->o_auth.authorizer);
> +		if (osd->o_auth.authorizer)
> +			ceph_auth_destroy_authorizer(ac, osd->o_auth.authorizer);
>  		kfree(osd);
>  	}
>  }
> 

--
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
diff mbox

Patch

diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index f693a2f8ac86..41a4abc7e98e 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -1035,10 +1035,11 @@  static void put_osd(struct ceph_osd *osd)
 {
 	dout("put_osd %p %d -> %d\n", osd, atomic_read(&osd->o_ref),
 	     atomic_read(&osd->o_ref) - 1);
-	if (atomic_dec_and_test(&osd->o_ref) && osd->o_auth.authorizer) {
+	if (atomic_dec_and_test(&osd->o_ref)) {
 		struct ceph_auth_client *ac = osd->o_osdc->client->monc.auth;
 
-		ceph_auth_destroy_authorizer(ac, osd->o_auth.authorizer);
+		if (osd->o_auth.authorizer)
+			ceph_auth_destroy_authorizer(ac, osd->o_auth.authorizer);
 		kfree(osd);
 	}
 }