[PATCH] knfsd: svcrpc: fix gss krb5i memory leak
authorJ.Bruce Fields <bfields@fieldses.org>
Wed, 13 Dec 2006 08:35:19 +0000 (00:35 -0800)
committerLinus Torvalds <torvalds@woody.osdl.org>
Wed, 13 Dec 2006 17:05:53 +0000 (09:05 -0800)
The memory leak here is embarassingly obvious.

This fixes a problem that causes the kernel to leak a small amount of memory
every time it receives a integrity-protected request.

Thanks to Aim Le Rouzic for the bug report.

Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
net/sunrpc/auth_gss/svcauth_gss.c

index 700353b330fd3ddaa359c95bd5b53f020c46aaab..3bf3520f92d11fa9733af97f8101a7c81ceba8fb 100644 (file)
@@ -804,19 +804,19 @@ unwrap_integ_data(struct xdr_buf *buf, u32 seq, struct gss_ctx *ctx)
 
        integ_len = svc_getnl(&buf->head[0]);
        if (integ_len & 3)
-               goto out;
+               return stat;
        if (integ_len > buf->len)
-               goto out;
+               return stat;
        if (xdr_buf_subsegment(buf, &integ_buf, 0, integ_len))
                BUG();
        /* copy out mic... */
        if (read_u32_from_xdr_buf(buf, integ_len, &mic.len))
                BUG();
        if (mic.len > RPC_MAX_AUTH_SIZE)
-               goto out;
+               return stat;
        mic.data = kmalloc(mic.len, GFP_KERNEL);
        if (!mic.data)
-               goto out;
+               return stat;
        if (read_bytes_from_xdr_buf(buf, integ_len + 4, mic.data, mic.len))
                goto out;
        maj_stat = gss_verify_mic(ctx, &integ_buf, &mic);
@@ -826,6 +826,7 @@ unwrap_integ_data(struct xdr_buf *buf, u32 seq, struct gss_ctx *ctx)
                goto out;
        stat = 0;
 out:
+       kfree(mic.data);
        return stat;
 }