lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 16 May 2017 14:32:38 -0400
From:   Paul Moore <paul@...l-moore.com>
To:     SF Markus Elfring <elfring@...rs.sourceforge.net>
Cc:     Casey Schaufler <casey@...aufler-ca.com>,
        Eric Paris <eparis@...isplace.org>,
        James Morris <james.l.morris@...cle.com>,
        "Serge E. Hallyn" <serge@...lyn.com>,
        Stephen Smalley <sds@...ho.nsa.gov>,
        William Roberts <william.c.roberts@...el.com>,
        linux-security-module@...r.kernel.org, selinux@...ho.nsa.gov,
        LKML <linux-kernel@...r.kernel.org>,
        kernel-janitors@...r.kernel.org
Subject: Re: [PATCH 2/3] selinux: Return an error code only as a constant in sidtab_insert()

On Tue, Apr 4, 2017 at 7:14 AM, SF Markus Elfring
<elfring@...rs.sourceforge.net> wrote:
> From: Markus Elfring <elfring@...rs.sourceforge.net>
> Date: Tue, 4 Apr 2017 11:33:53 +0200
>
> * Return an error code without storing it in an intermediate variable.
>
> * Delete the local variable "rc" and the jump label "out" which became
>   unnecessary with this refactoring.
>
> Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
> ---
>  security/selinux/ss/sidtab.c | 27 ++++++++++-----------------
>  1 file changed, 10 insertions(+), 17 deletions(-)

Merged.

> diff --git a/security/selinux/ss/sidtab.c b/security/selinux/ss/sidtab.c
> index f6915f257486..c5f436b15d19 100644
> --- a/security/selinux/ss/sidtab.c
> +++ b/security/selinux/ss/sidtab.c
> @@ -32,13 +32,11 @@ int sidtab_init(struct sidtab *s)
>
>  int sidtab_insert(struct sidtab *s, u32 sid, struct context *context)
>  {
> -       int hvalue, rc = 0;
> +       int hvalue;
>         struct sidtab_node *prev, *cur, *newnode;
>
> -       if (!s) {
> -               rc = -ENOMEM;
> -               goto out;
> -       }
> +       if (!s)
> +               return -ENOMEM;
>
>         hvalue = SIDTAB_HASH(sid);
>         prev = NULL;
> @@ -48,21 +46,17 @@ int sidtab_insert(struct sidtab *s, u32 sid, struct context *context)
>                 cur = cur->next;
>         }
>
> -       if (cur && sid == cur->sid) {
> -               rc = -EEXIST;
> -               goto out;
> -       }
> +       if (cur && sid == cur->sid)
> +               return -EEXIST;
>
>         newnode = kmalloc(sizeof(*newnode), GFP_ATOMIC);
> -       if (!newnode) {
> -               rc = -ENOMEM;
> -               goto out;
> -       }
> +       if (!newnode)
> +               return -ENOMEM;
> +
>         newnode->sid = sid;
>         if (context_cpy(&newnode->context, context)) {
>                 kfree(newnode);
> -               rc = -ENOMEM;
> -               goto out;
> +               return -ENOMEM;
>         }
>
>         if (prev) {
> @@ -78,8 +72,7 @@ int sidtab_insert(struct sidtab *s, u32 sid, struct context *context)
>         s->nel++;
>         if (sid >= s->next_sid)
>                 s->next_sid = sid + 1;
> -out:
> -       return rc;
> +       return 0;
>  }
>
>  static struct context *sidtab_search_core(struct sidtab *s, u32 sid, int force)
> --
> 2.12.2
>



-- 
paul moore
www.paul-moore.com

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ