From: Trond Myklebust Date: Fri, 18 Dec 2009 21:28:05 +0000 (-0500) Subject: SUNRPC: Fix up an error return value in gss_import_sec_context_kerberos() X-Git-Tag: firefly_0821_release~11625^2~376 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=e64b13f62782f5e495c085e1c06e48224545617f;p=firefly-linux-kernel-4.4.55.git SUNRPC: Fix up an error return value in gss_import_sec_context_kerberos() commit 14ace024b1e16d2bb9445c8387494fbbd820a738 upstream. If the context allocation fails, the function currently returns a random error code, since the variable 'p' still points to a valid memory location. Ensure that it returns ENOMEM... Signed-off-by: Trond Myklebust Signed-off-by: Greg Kroah-Hartman --- diff --git a/net/sunrpc/auth_gss/gss_krb5_mech.c b/net/sunrpc/auth_gss/gss_krb5_mech.c index ef45eba22485..2deb0ed72ff4 100644 --- a/net/sunrpc/auth_gss/gss_krb5_mech.c +++ b/net/sunrpc/auth_gss/gss_krb5_mech.c @@ -131,8 +131,10 @@ gss_import_sec_context_kerberos(const void *p, struct krb5_ctx *ctx; int tmp; - if (!(ctx = kzalloc(sizeof(*ctx), GFP_NOFS))) + if (!(ctx = kzalloc(sizeof(*ctx), GFP_NOFS))) { + p = ERR_PTR(-ENOMEM); goto out_err; + } p = simple_get_bytes(p, end, &ctx->initiate, sizeof(ctx->initiate)); if (IS_ERR(p))