Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/security-testing-2.6

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/security-testing-2.6:
  SELinux: memory leak in security_context_to_sid_core
This commit is contained in:
Linus Torvalds 2008-09-03 17:57:55 -07:00
commit d210baf53b

View file

@ -811,11 +811,12 @@ static int string_to_context_struct(struct policydb *pol,
/* Check the validity of the new context. */ /* Check the validity of the new context. */
if (!policydb_context_isvalid(pol, ctx)) { if (!policydb_context_isvalid(pol, ctx)) {
rc = -EINVAL; rc = -EINVAL;
context_destroy(ctx);
goto out; goto out;
} }
rc = 0; rc = 0;
out: out:
if (rc)
context_destroy(ctx);
return rc; return rc;
} }
@ -868,8 +869,7 @@ static int security_context_to_sid_core(const char *scontext, u32 scontext_len,
} else if (rc) } else if (rc)
goto out; goto out;
rc = sidtab_context_to_sid(&sidtab, &context, sid); rc = sidtab_context_to_sid(&sidtab, &context, sid);
if (rc) context_destroy(&context);
context_destroy(&context);
out: out:
read_unlock(&policy_rwlock); read_unlock(&policy_rwlock);
kfree(scontext2); kfree(scontext2);