From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751398AbdAOPpY (ORCPT ); Sun, 15 Jan 2017 10:45:24 -0500 Received: from mout.web.de ([212.227.15.14]:57341 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751098AbdAOPpW (ORCPT ); Sun, 15 Jan 2017 10:45:22 -0500 Subject: [PATCH 45/46] selinux: Use common error handling code in sidtab_insert() To: linux-security-module@vger.kernel.org, selinux@tycho.nsa.gov, Eric Paris , James Morris , Paul Moore , "Serge E. Hallyn" , Stephen Smalley , William Roberts References: Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Message-ID: <36f95c73-4ae1-efbf-393c-6f4239a91478@users.sourceforge.net> Date: Sun, 15 Jan 2017 16:45:05 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:uI16RxgtW15BGmH61B3IyLWKsdjYxaOdmT1wGiYQEMcjsjfZCeR vGENHbFRZGBvebz+5cVgESkwuvl0Wz1vefCuxNlXh6PN8SxcsZvhJ/BTsV3B0WvYMebNPhD T3U/ljCv3AaE7GD9mG7Fick9A0CdReMrdf7EAFLEwSFrGWi0Iqr/uBRNuA7o0wScQPxZTzZ EYKpA9OeeNc/NHZ0NsJkg== X-UI-Out-Filterresults: notjunk:1;V01:K0:5BTjB/CVaw8=:SqRBP3YUaTHM3bZCHsYhAe 0oN+9zqLs5ys8QX/RM7P5p3tqTWWpjqnxGpacrRsg9JIeBgvNyhsx0T01UWON3HPS+HOCBvUL lVuBedy7Gl0SiPOf9EQnUI8DM3JMlT37SN/bpsluvVPtTSTX84W6tdNE/JwgGB7CPM0TPVRjs 9bYmw1AtULmdlW9zmZ5vkBdSM5i8JRiFwfynWcAT7wOWlurua6CdNOiUZwGTdOkOIdLS+oPrh D4A0FMiiJWr9b05t6/nvuU8URbC3USK5h/AzkQvWMm/kNZorYVRM8d/mLayU+XMBOBNjzqjqP rAxZz6GD9ZQqsQx/pKqjnVzj3JrQXmpA/bYuJ5dJWYHzYZzF3yXFUvt7LweewwJq4SefLSC/x miNwU0qwB5u2nWVPDnBdf9O6cH1JBNdFu0J4uvQTB8uiVbb1EAmCU6D1K/vK8973fx6WnnuYV mnQL3R9XRzQk/qqmSQivee0J2aVyi+ofs+h08SQgZz+etusyi8UDowWcBhyoxEhAfyBU2Odb4 /8H3evprKSTcbUgqa3crcNbK3iSUC1+hybx0wXDsSyp+NWcODrCRXmL2HZSkdUSk1n0C/rKzc FlJ0zpHYRFQzgFXsxwgxYkhed977NSJhnUyjtIJDxaKugdkIadfTDV04ieswQWBxW15F3Cqdo KV7IRKC0EMtIHI5GpCNZg+q/j3kYNNwaI1Q9q2ExwiKdCyafojJRZnGmSDIZ13FsLykbJtaxz iR8gIxKUqeIJD55iFXaxzwOzH/tduEHJCvlNVzdGXprEN3mHsfTVShqJQYDTHu4w3WMajExtm mOvawAG Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Markus Elfring Date: Sun, 15 Jan 2017 13:45:45 +0100 Add a jump target so that a bit of exception handling can be better reused at the end of this function. Signed-off-by: Markus Elfring --- security/selinux/ss/sidtab.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/security/selinux/ss/sidtab.c b/security/selinux/ss/sidtab.c index f6915f257486..4130f882808c 100644 --- a/security/selinux/ss/sidtab.c +++ b/security/selinux/ss/sidtab.c @@ -35,10 +35,8 @@ int sidtab_insert(struct sidtab *s, u32 sid, struct context *context) int hvalue, rc = 0; struct sidtab_node *prev, *cur, *newnode; - if (!s) { - rc = -ENOMEM; - goto out; - } + if (!s) + goto failure_indication; hvalue = SIDTAB_HASH(sid); prev = NULL; @@ -54,15 +52,12 @@ int sidtab_insert(struct sidtab *s, u32 sid, struct context *context) } newnode = kmalloc(sizeof(*newnode), GFP_ATOMIC); - if (!newnode) { - rc = -ENOMEM; - goto out; - } + if (!newnode) + goto failure_indication; newnode->sid = sid; if (context_cpy(&newnode->context, context)) { kfree(newnode); - rc = -ENOMEM; - goto out; + goto failure_indication; } if (prev) { @@ -80,6 +75,9 @@ int sidtab_insert(struct sidtab *s, u32 sid, struct context *context) s->next_sid = sid + 1; out: return rc; +failure_indication: + rc = -ENOMEM; + goto out; } static struct context *sidtab_search_core(struct sidtab *s, u32 sid, int force) -- 2.11.0 From mboxrd@z Thu Jan 1 00:00:00 1970 From: SF Markus Elfring Date: Sun, 15 Jan 2017 15:45:05 +0000 Subject: [PATCH 45/46] selinux: Use common error handling code in sidtab_insert() Message-Id: <36f95c73-4ae1-efbf-393c-6f4239a91478@users.sourceforge.net> List-Id: References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-security-module@vger.kernel.org, selinux@tycho.nsa.gov, Eric Paris , James Morris , Paul Moore , "Serge E. Hallyn" , Stephen Smalley , William Roberts Cc: LKML , kernel-janitors@vger.kernel.org From: Markus Elfring Date: Sun, 15 Jan 2017 13:45:45 +0100 Add a jump target so that a bit of exception handling can be better reused at the end of this function. Signed-off-by: Markus Elfring --- security/selinux/ss/sidtab.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/security/selinux/ss/sidtab.c b/security/selinux/ss/sidtab.c index f6915f257486..4130f882808c 100644 --- a/security/selinux/ss/sidtab.c +++ b/security/selinux/ss/sidtab.c @@ -35,10 +35,8 @@ int sidtab_insert(struct sidtab *s, u32 sid, struct context *context) int hvalue, rc = 0; struct sidtab_node *prev, *cur, *newnode; - if (!s) { - rc = -ENOMEM; - goto out; - } + if (!s) + goto failure_indication; hvalue = SIDTAB_HASH(sid); prev = NULL; @@ -54,15 +52,12 @@ int sidtab_insert(struct sidtab *s, u32 sid, struct context *context) } newnode = kmalloc(sizeof(*newnode), GFP_ATOMIC); - if (!newnode) { - rc = -ENOMEM; - goto out; - } + if (!newnode) + goto failure_indication; newnode->sid = sid; if (context_cpy(&newnode->context, context)) { kfree(newnode); - rc = -ENOMEM; - goto out; + goto failure_indication; } if (prev) { @@ -80,6 +75,9 @@ int sidtab_insert(struct sidtab *s, u32 sid, struct context *context) s->next_sid = sid + 1; out: return rc; +failure_indication: + rc = -ENOMEM; + goto out; } static struct context *sidtab_search_core(struct sidtab *s, u32 sid, int force) -- 2.11.0