Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1612079 > unrolled thread

Re: [PATCH 42/46] selinux: One function call less in roles_init() after error detection

Started byPaul Moore <paul@paul-moore.com>
First post2017-03-29 17:50 +0200
Last post2017-03-29 17:50 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH 42/46] selinux: One function call less in roles_init()  after error detection Paul Moore <paul@paul-moore.com> - 2017-03-29 17:50 +0200

#1612079 — Re: [PATCH 42/46] selinux: One function call less in roles_init() after error detection

FromPaul Moore <paul@paul-moore.com>
Date2017-03-29 17:50 +0200
SubjectRe: [PATCH 42/46] selinux: One function call less in roles_init() after error detection
Message-ID<tqo1c-xp-9@gated-at.bofh.it>
On Sun, Jan 15, 2017 at 10:42 AM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 15 Jan 2017 12:56:54 +0100
>
> The kfree() function was called in up to two cases by the
> roles_init() function during error handling even if the passed variable
> contained a null pointer.
>
> * Adjust a jump target according to the Linux coding style convention.
>
> * Delete an initialisation for the variable "key" at the beginning
>   which became unnecessary with this refactoring.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  security/selinux/ss/policydb.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)

Dropped due to unnecessary code churn with no significant advantage.

> diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c
> index be445abf047b..7dd5c6f7786f 100644
> --- a/security/selinux/ss/policydb.c
> +++ b/security/selinux/ss/policydb.c
> @@ -174,7 +174,7 @@ static struct policydb_compat_info *policydb_lookup_compat(int version)
>   */
>  static int roles_init(struct policydb *p)
>  {
> -       char *key = NULL;
> +       char *key;
>         int rc;
>         struct role_datum *role;
>
> @@ -185,13 +185,13 @@ static int roles_init(struct policydb *p)
>         role->value = ++p->p_roles.nprim;
>         if (role->value != OBJECT_R_VAL) {
>                 rc = -EINVAL;
> -               goto out;
> +               goto free_role;
>         }
>
>         key = kstrdup(OBJECT_R, GFP_KERNEL);
>         if (!key) {
>                 rc = -ENOMEM;
> -               goto out;
> +               goto free_role;
>         }
>
>         rc = hashtab_insert(p->p_roles.table, key, role);
> @@ -201,6 +201,7 @@ static int roles_init(struct policydb *p)
>         return 0;
>  out:
>         kfree(key);
> +free_role:
>         kfree(role);
>         return rc;
>  }
> --
> 2.11.0
>



-- 
paul moore
www.paul-moore.com

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web