[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHC9VhTtxZsUyWDga4tZC0hEUO3L8s0jFqy9L=TWqZiHts5=eQ@mail.gmail.com>
Date: Thu, 23 Mar 2017 18:05:29 -0400
From: Paul Moore <paul@...l-moore.com>
To: Casey Schaufler <casey@...aufler-ca.com>
Cc: SF Markus Elfring <elfring@...rs.sourceforge.net>,
linux-security-module@...r.kernel.org, selinux@...ho.nsa.gov,
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>,
LKML <linux-kernel@...r.kernel.org>,
kernel-janitors@...r.kernel.org
Subject: Re: [PATCH 15/46] selinux: One check and function call less in
genfs_read() after error detection
On Tue, Jan 17, 2017 at 12:53 PM, Casey Schaufler
<casey@...aufler-ca.com> wrote:
> On 1/17/2017 8:37 AM, SF Markus Elfring wrote:
>>>> @@ -2015,7 +2015,7 @@ static int genfs_read(struct policydb *p, void *fp)
>>>> newgenfs = kzalloc(sizeof(*newgenfs), GFP_KERNEL);
>>>> if (!newgenfs) {
>>>> rc = -ENOMEM;
>>>> - goto out;
>>>> + goto exit;
>>>> }
>>>>
>>>> rc = str_read(&newgenfs->fstype, GFP_KERNEL, fp, len);
>>>> @@ -2101,7 +2101,7 @@ static int genfs_read(struct policydb *p, void *fp)
>>>> kfree(newgenfs);
>>>> }
>>>> ocontext_destroy(newc, OCON_FSUSE);
>>>> -
>>>> +exit:
>>>> return rc;
>>> Why not replace the "goto out" with "return rc" rather
>>> than add a target?
>> Would you accept to use the statement "return -ENOMEM;" there instead?
>
> That would be even better.
I *hate* code that does a jump to a label only to then do a
return/exit. That said, see my earlier comments about not worrying
too much about performance of the error path and in this case I like
the "feel good" nature of the code where ever failure in the loop goes
to "out".
--
paul moore
www.paul-moore.com
Powered by blists - more mailing lists