* [patch 6/7] selinux: fix error codes in cond_read_bool()
@ 2010-06-07 21:10 Dan Carpenter
2010-06-08 20:22 ` Eric Paris
2010-06-08 23:35 ` James Morris
0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2010-06-07 21:10 UTC (permalink / raw)
To: kernel-janitors
The original code always returned -1 (-EPERM) on error. The new code
returns either -ENOMEM, or -EINVAL or it propagates the error codes from
lower level functions next_entry() or hashtab_insert().
next_entry() returns -EINVAL.
hashtab_insert() returns -EINVAL, -EEXIST, or -ENOMEM.
Signed-off-by: Dan Carpenter <error27@gmail.com>
diff --git a/security/selinux/ss/conditional.c b/security/selinux/ss/conditional.c
index 7447be0..dc5db55 100644
--- a/security/selinux/ss/conditional.c
+++ b/security/selinux/ss/conditional.c
@@ -223,7 +223,7 @@ int cond_read_bool(struct policydb *p, struct hashtab *h, void *fp)
booldatum = kzalloc(sizeof(struct cond_bool_datum), GFP_KERNEL);
if (!booldatum)
- return -1;
+ return -ENOMEM;
rc = next_entry(buf, fp, sizeof buf);
if (rc < 0)
@@ -232,11 +232,13 @@ int cond_read_bool(struct policydb *p, struct hashtab *h, void *fp)
booldatum->value = le32_to_cpu(buf[0]);
booldatum->state = le32_to_cpu(buf[1]);
+ rc = -EINVAL;
if (!bool_isvalid(booldatum))
goto err;
len = le32_to_cpu(buf[2]);
+ rc = -ENOMEM;
key = kmalloc(len + 1, GFP_KERNEL);
if (!key)
goto err;
@@ -244,13 +246,14 @@ int cond_read_bool(struct policydb *p, struct hashtab *h, void *fp)
if (rc < 0)
goto err;
key[len] = '\0';
- if (hashtab_insert(h, key, booldatum))
+ rc = hashtab_insert(h, key, booldatum);
+ if (rc < 0)
goto err;
return 0;
err:
cond_destroy_bool(key, booldatum, NULL);
- return -1;
+ return rc;
}
struct cond_insertf_data {
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [patch 6/7] selinux: fix error codes in cond_read_bool()
2010-06-07 21:10 [patch 6/7] selinux: fix error codes in cond_read_bool() Dan Carpenter
@ 2010-06-08 20:22 ` Eric Paris
2010-06-08 23:35 ` James Morris
1 sibling, 0 replies; 3+ messages in thread
From: Eric Paris @ 2010-06-08 20:22 UTC (permalink / raw)
To: kernel-janitors
On Mon, Jun 7, 2010 at 5:10 PM, Dan Carpenter <error27@gmail.com> wrote:
> The original code always returned -1 (-EPERM) on error. The new code
> returns either -ENOMEM, or -EINVAL or it propagates the error codes from
> lower level functions next_entry() or hashtab_insert().
>
> next_entry() returns -EINVAL.
> hashtab_insert() returns -EINVAL, -EEXIST, or -ENOMEM.
>
> Signed-off-by: Dan Carpenter <error27@gmail.com>
>
> diff --git a/security/selinux/ss/conditional.c b/security/selinux/ss/conditional.c
> index 7447be0..dc5db55 100644
> --- a/security/selinux/ss/conditional.c
> +++ b/security/selinux/ss/conditional.c
> @@ -244,13 +246,14 @@ int cond_read_bool(struct policydb *p, struct hashtab *h, void *fp)
> if (rc < 0)
> goto err;
> key[len] = '\0';
> - if (hashtab_insert(h, key, booldatum))
> + rc = hashtab_insert(h, key, booldatum);
> + if (rc < 0)
If James wants to pull this one I'm ok with it, but I much prefer if (rc)
-Eric
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch 6/7] selinux: fix error codes in cond_read_bool()
2010-06-07 21:10 [patch 6/7] selinux: fix error codes in cond_read_bool() Dan Carpenter
2010-06-08 20:22 ` Eric Paris
@ 2010-06-08 23:35 ` James Morris
1 sibling, 0 replies; 3+ messages in thread
From: James Morris @ 2010-06-08 23:35 UTC (permalink / raw)
To: kernel-janitors
On Tue, 8 Jun 2010, Eric Paris wrote:
> If James wants to pull this one I'm ok with it, but I much prefer if (rc)
I'd prefer to see them resent with your feedback incorporated.
--
James Morris
<jmorris@namei.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-06-08 23:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-07 21:10 [patch 6/7] selinux: fix error codes in cond_read_bool() Dan Carpenter
2010-06-08 20:22 ` Eric Paris
2010-06-08 23:35 ` James Morris
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox