linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] selinux: return -ENOMEM when memory allocation fails
@ 2011-01-20 18:31 Davidlohr Bueso
  2011-01-21  0:07 ` James Morris
  0 siblings, 1 reply; 4+ messages in thread
From: Davidlohr Bueso @ 2011-01-20 18:31 UTC (permalink / raw)
  To: Stephen Smalley, James Morris, Eric Paris; +Cc: LKML

From: Davidlohr Bueso <dave@gnu.org>

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
---
 security/selinux/ss/conditional.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/security/selinux/ss/conditional.c b/security/selinux/ss/conditional.c
index c3f845c..a533732 100644
--- a/security/selinux/ss/conditional.c
+++ b/security/selinux/ss/conditional.c
@@ -178,7 +178,7 @@ int cond_init_bool_indexes(struct policydb *p)
 	p->bool_val_to_struct = (struct cond_bool_datum **)
 		kmalloc(p->p_bools.nprim * sizeof(struct cond_bool_datum *), GFP_KERNEL);
 	if (!p->bool_val_to_struct)
-		return -1;
+		return -ENOMEM;
 	return 0;
 }
 
-- 
1.7.1






^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/3] selinux: return -ENOMEM when memory allocation fails
  2011-01-20 18:31 [PATCH 1/3] selinux: return -ENOMEM when memory allocation fails Davidlohr Bueso
@ 2011-01-21  0:07 ` James Morris
  2011-01-21 15:28   ` Davidlohr Bueso
  0 siblings, 1 reply; 4+ messages in thread
From: James Morris @ 2011-01-21  0:07 UTC (permalink / raw)
  To: Davidlohr Bueso; +Cc: Stephen Smalley, Eric Paris, LKML, selinux

On Thu, 20 Jan 2011, Davidlohr Bueso wrote:

> From: Davidlohr Bueso <dave@gnu.org>
> 
> Signed-off-by: Davidlohr Bueso <dave@gnu.org>
> ---
>  security/selinux/ss/conditional.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/security/selinux/ss/conditional.c b/security/selinux/ss/conditional.c
> index c3f845c..a533732 100644
> --- a/security/selinux/ss/conditional.c
> +++ b/security/selinux/ss/conditional.c
> @@ -178,7 +178,7 @@ int cond_init_bool_indexes(struct policydb *p)
>  	p->bool_val_to_struct = (struct cond_bool_datum **)
>  		kmalloc(p->p_bools.nprim * sizeof(struct cond_bool_datum *), GFP_KERNEL);
>  	if (!p->bool_val_to_struct)
> -		return -1;
> +		return -ENOMEM;
>  	return 0;

The caller has already set -ENOMEM, so the code should probably be updated 
there, too, e.g.

	rc = cond_init_bool_indexes();
	if (rc)
		goto out;



-- 
James Morris
<jmorris@namei.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/3] selinux: return -ENOMEM when memory allocation fails
  2011-01-21  0:07 ` James Morris
@ 2011-01-21 15:28   ` Davidlohr Bueso
  2011-01-24  0:41     ` James Morris
  0 siblings, 1 reply; 4+ messages in thread
From: Davidlohr Bueso @ 2011-01-21 15:28 UTC (permalink / raw)
  To: James Morris; +Cc: Stephen Smalley, Eric Paris, LKML, selinux

On Fri, 2011-01-21 at 11:07 +1100, James Morris wrote:
> On Thu, 20 Jan 2011, Davidlohr Bueso wrote:
> 
> > From: Davidlohr Bueso <dave@gnu.org>
> > 
> > Signed-off-by: Davidlohr Bueso <dave@gnu.org>
> > ---
> >  security/selinux/ss/conditional.c |    2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> > 
> > diff --git a/security/selinux/ss/conditional.c b/security/selinux/ss/conditional.c
> > index c3f845c..a533732 100644
> > --- a/security/selinux/ss/conditional.c
> > +++ b/security/selinux/ss/conditional.c
> > @@ -178,7 +178,7 @@ int cond_init_bool_indexes(struct policydb *p)
> >  	p->bool_val_to_struct = (struct cond_bool_datum **)
> >  		kmalloc(p->p_bools.nprim * sizeof(struct cond_bool_datum *), GFP_KERNEL);
> >  	if (!p->bool_val_to_struct)
> > -		return -1;
> > +		return -ENOMEM;
> >  	return 0;
> 
> The caller has already set -ENOMEM, so the code should probably be updated 
> there, too, e.g.
> 
> 	rc = cond_init_bool_indexes();
> 	if (rc)
> 		goto out;

Ah yes, thanks for pointing this out.

From: Davidlohr Bueso <dave@gnu.org>
Date: Fri, 21 Jan 2011 12:26:51 -0300
Subject: [PATCH] selinux: return -ENOMEM when memory allocation fails

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
---
 security/selinux/ss/conditional.c |    2 +-
 security/selinux/ss/policydb.c    |    6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/security/selinux/ss/conditional.c b/security/selinux/ss/conditional.c
index c3f845c..a533732 100644
--- a/security/selinux/ss/conditional.c
+++ b/security/selinux/ss/conditional.c
@@ -178,7 +178,7 @@ int cond_init_bool_indexes(struct policydb *p)
 	p->bool_val_to_struct = (struct cond_bool_datum **)
 		kmalloc(p->p_bools.nprim * sizeof(struct cond_bool_datum *), GFP_KERNEL);
 	if (!p->bool_val_to_struct)
-		return -1;
+		return -ENOMEM;
 	return 0;
 }
 
diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c
index be9de38..0ebf5b5 100644
--- a/security/selinux/ss/policydb.c
+++ b/security/selinux/ss/policydb.c
@@ -500,9 +500,9 @@ static int policydb_index(struct policydb *p)
 				 p->p_types.nprim - 1, GFP_KERNEL | __GFP_ZERO);
 	if (rc)
 		goto out;
-
-	rc = -ENOMEM;
-	if (cond_init_bool_indexes(p))
+	
+	rc = cond_init_bool_indexes(p);
+	if (rc)
 		goto out;
 
 	for (i = 0; i < SYM_NUM; i++) {
-- 
1.7.1





^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/3] selinux: return -ENOMEM when memory allocation fails
  2011-01-21 15:28   ` Davidlohr Bueso
@ 2011-01-24  0:41     ` James Morris
  0 siblings, 0 replies; 4+ messages in thread
From: James Morris @ 2011-01-24  0:41 UTC (permalink / raw)
  To: Davidlohr Bueso; +Cc: Stephen Smalley, Eric Paris, LKML, selinux

On Fri, 21 Jan 2011, Davidlohr Bueso wrote:

> 
> From: Davidlohr Bueso <dave@gnu.org>
> Date: Fri, 21 Jan 2011 12:26:51 -0300
> Subject: [PATCH] selinux: return -ENOMEM when memory allocation fails
> 
> Signed-off-by: Davidlohr Bueso <dave@gnu.org>
> ---
>  security/selinux/ss/conditional.c |    2 +-
>  security/selinux/ss/policydb.c    |    6 +++---
>  2 files changed, 4 insertions(+), 4 deletions(-)

Applied to
git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/security-testing-2.6#for-linus

-- 
James Morris
<jmorris@namei.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-01-24  0:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-20 18:31 [PATCH 1/3] selinux: return -ENOMEM when memory allocation fails Davidlohr Bueso
2011-01-21  0:07 ` James Morris
2011-01-21 15:28   ` Davidlohr Bueso
2011-01-24  0:41     ` James Morris

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).