From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751172AbdAQQf2 (ORCPT ); Tue, 17 Jan 2017 11:35:28 -0500 Received: from nm16-vm6.bullet.mail.ne1.yahoo.com ([98.138.91.109]:33869 "EHLO nm16-vm6.bullet.mail.ne1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750933AbdAQQf0 (ORCPT ); Tue, 17 Jan 2017 11:35:26 -0500 X-Yahoo-Newman-Id: 682569.52298.bm@smtp215.mail.ne1.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: kr1FmZsVM1npzl7Xg1vyU8r756KB2K9UCK5mSRcejbWZ4eE IwZEGXFOq6iAWs5K7R.WhNnHF08ZHu9Hui0cOTZh_ttFLWuNEQ79M.PZJcMz on0DErAdVcaKhyumlUpVbgoFMZb.8VYIK90K3Go0ABowHmIbX0askx68QO31 F4qPFfX4W6KzoXtJxywY3H3qOCHfe1gZtNlelrviO1CM5DBuFFa3cgd2N8fD MUlSjgwO2di5Q.mbevHiDDy.TzduS4Qz4hPIyfIUxfMKOrvafNrBpR4B.uiS J0DQh82LUdhb02ZUskBceRpHmKfU14bbD_xixbFBH91Yg7h6C_Lv9wHFEBBT aGXX57NUhSTsplPPfswhCLW6U_i2FIWGFyJ54l4VqMUiVeota0mUIv3G53.O hXZir3n8RSRyo2B.kfFnpdrVuaApTo4WyIz9lR3mxpj1xcQfxOglBz_Didhc rdf992ppAgsYHUc_ikvxmXz6LfIjAnjWrhVMn_U1rjaOegXlLqJPWYbmm5qc fzh.steDRBFce.u1w6kXAolGxnvN4DAgruNdFROJlPrescXVOCIqaAXA- X-Yahoo-SMTP: OIJXglSswBDfgLtXluJ6wiAYv6_cnw-- Subject: Re: [PATCH 21/46] selinux: Two function calls less in range_read() after error detection To: SF Markus Elfring , linux-security-module@vger.kernel.org, selinux@tycho.nsa.gov, Eric Paris , James Morris , Paul Moore , "Serge E. Hallyn" , Stephen Smalley , William Roberts References: <1e37fe86-2e83-c1f0-f43b-69ed2fb5c7aa@users.sourceforge.net> Cc: LKML , kernel-janitors@vger.kernel.org From: Casey Schaufler Message-ID: Date: Tue, 17 Jan 2017 08:35:23 -0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: <1e37fe86-2e83-c1f0-f43b-69ed2fb5c7aa@users.sourceforge.net> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/15/2017 7:21 AM, SF Markus Elfring wrote: > From: Markus Elfring > Date: Sat, 14 Jan 2017 20:20:15 +0100 > > Adjust a jump target to avoid two calls of the function "kfree" at the end > after a memory allocation failed for the local variable "rt". > > Signed-off-by: Markus Elfring > --- > security/selinux/ss/policydb.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c > index 4cd96ce51322..0d2f64558c0a 100644 > --- a/security/selinux/ss/policydb.c > +++ b/security/selinux/ss/policydb.c > @@ -1857,7 +1857,7 @@ static int range_read(struct policydb *p, void *fp) > rt = kzalloc(sizeof(*rt), GFP_KERNEL); > if (!rt) { > rc = -ENOMEM; > - goto out; > + goto exit; Why not "return rc;"? goto to a return is wrong. > } > > rc = next_entry(buf, fp, (sizeof(u32) * 2)); > @@ -1909,6 +1909,7 @@ static int range_read(struct policydb *p, void *fp) > out: > kfree(rt); > kfree(r); > +exit: > return rc; > } > From mboxrd@z Thu Jan 1 00:00:00 1970 From: Casey Schaufler Date: Tue, 17 Jan 2017 16:35:23 +0000 Subject: Re: [PATCH 21/46] selinux: Two function calls less in range_read() after error detection Message-Id: List-Id: References: <1e37fe86-2e83-c1f0-f43b-69ed2fb5c7aa@users.sourceforge.net> In-Reply-To: <1e37fe86-2e83-c1f0-f43b-69ed2fb5c7aa@users.sourceforge.net> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: SF Markus Elfring , 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 On 1/15/2017 7:21 AM, SF Markus Elfring wrote: > From: Markus Elfring > Date: Sat, 14 Jan 2017 20:20:15 +0100 > > Adjust a jump target to avoid two calls of the function "kfree" at the end > after a memory allocation failed for the local variable "rt". > > Signed-off-by: Markus Elfring > --- > security/selinux/ss/policydb.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c > index 4cd96ce51322..0d2f64558c0a 100644 > --- a/security/selinux/ss/policydb.c > +++ b/security/selinux/ss/policydb.c > @@ -1857,7 +1857,7 @@ static int range_read(struct policydb *p, void *fp) > rt = kzalloc(sizeof(*rt), GFP_KERNEL); > if (!rt) { > rc = -ENOMEM; > - goto out; > + goto exit; Why not "return rc;"? goto to a return is wrong. > } > > rc = next_entry(buf, fp, (sizeof(u32) * 2)); > @@ -1909,6 +1909,7 @@ static int range_read(struct policydb *p, void *fp) > out: > kfree(rt); > kfree(r); > +exit: > return rc; > } >