Commit d210baf53b699fc61aa891c177b71d7082d3b957

Authored by Linus Torvalds

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorri…

…s/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

Showing 1 changed file Side-by-side Diff

security/selinux/ss/services.c
... ... @@ -811,11 +811,12 @@
811 811 /* Check the validity of the new context. */
812 812 if (!policydb_context_isvalid(pol, ctx)) {
813 813 rc = -EINVAL;
814   - context_destroy(ctx);
815 814 goto out;
816 815 }
817 816 rc = 0;
818 817 out:
  818 + if (rc)
  819 + context_destroy(ctx);
819 820 return rc;
820 821 }
821 822  
... ... @@ -868,8 +869,7 @@
868 869 } else if (rc)
869 870 goto out;
870 871 rc = sidtab_context_to_sid(&sidtab, &context, sid);
871   - if (rc)
872   - context_destroy(&context);
  872 + context_destroy(&context);
873 873 out:
874 874 read_unlock(&policy_rwlock);
875 875 kfree(scontext2);