summaryrefslogtreecommitdiffstats
path: root/wrapper.c
diff options
context:
space:
mode:
authorDhaval Giani <dhaval@linux.vnet.ibm.com>2008-09-05 18:53:13 +0000
committerDhaval Giani <dhaval@linux.vnet.ibm.com>2008-09-05 18:53:13 +0000
commit096af9029b89dc982e3849bcb3da49268abcd2cb (patch)
tree1340709ce5bb8e5c319c6263fa088c901248dab9 /wrapper.c
parenteb6cf0c1d25837f4816e0a253a46118bfb05baef (diff)
downloadlibcg-096af9029b89dc982e3849bcb3da49268abcd2cb.tar.gz
libcg-096af9029b89dc982e3849bcb3da49268abcd2cb.tar.xz
libcg-096af9029b89dc982e3849bcb3da49268abcd2cb.zip
libcgroup: Check for NULL data structures in the wrappers
Don't want to have a segmentation fault for NULL data structures. Just return an error to the caller. Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@177 4f4bb910-9a46-0410-90c8-c897d4f1cd53
Diffstat (limited to 'wrapper.c')
-rw-r--r--wrapper.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/wrapper.c b/wrapper.c
index c75552b..b808f72 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -41,6 +41,9 @@ struct cgroup_controller *cgroup_add_controller(struct cgroup *cgroup,
int i;
struct cgroup_controller *controller;
+ if (!cgroup)
+ return NULL;
+
/*
* Still not sure how to handle the failure here.
*/
@@ -101,6 +104,9 @@ int cgroup_add_value_string(struct cgroup_controller *controller,
int i;
struct control_value *cntl_value;
+ if (!controller)
+ return ECGINVAL;
+
if (controller->index >= CG_VALUE_MAX)
return ECGMAXVALUESEXCEEDED;
@@ -129,6 +135,9 @@ int cgroup_add_value_int64(struct cgroup_controller *controller,
unsigned ret;
struct control_value *cntl_value;
+ if (!controller)
+ return ECGINVAL;
+
if (controller->index >= CG_VALUE_MAX)
return ECGMAXVALUESEXCEEDED;
@@ -164,6 +173,9 @@ int cgroup_add_value_uint64(struct cgroup_controller *controller,
unsigned ret;
struct control_value *cntl_value;
+ if (!controller)
+ return ECGINVAL;
+
if (controller->index >= CG_VALUE_MAX)
return ECGMAXVALUESEXCEEDED;
@@ -198,6 +210,9 @@ int cgroup_add_value_bool(struct cgroup_controller *controller,
unsigned ret;
struct control_value *cntl_value;
+ if (!controller)
+ return ECGINVAL;
+
if (controller->index >= CG_VALUE_MAX)
return ECGMAXVALUESEXCEEDED;
@@ -323,6 +338,9 @@ struct cgroup_controller *cgroup_get_controller(struct cgroup *cgroup,
int i;
struct cgroup_controller *cgc;
+ if (!cgroup)
+ return NULL;
+
for (i = 0; i < cgroup->index; i++) {
cgc = cgroup->controller[i];
@@ -338,6 +356,9 @@ int cgroup_get_value_string(struct cgroup_controller *controller,
{
int i;
+ if (!controller)
+ return ECGINVAL;
+
for (i = 0; i < controller->index; i++) {
struct control_value *val = controller->values[i];
@@ -360,6 +381,9 @@ int cgroup_set_value_string(struct cgroup_controller *controller,
{
int i;
+ if (!controller)
+ return ECGINVAL;
+
for (i = 0; i < controller->index; i++) {
struct control_value *val = controller->values[i];
if (!strcmp(val->name, name)) {
@@ -376,6 +400,9 @@ int cgroup_get_value_int64(struct cgroup_controller *controller,
{
int i;
+ if (!controller)
+ return ECGINVAL;
+
for (i = 0; i < controller->index; i++) {
struct control_value *val = controller->values[i];
@@ -397,6 +424,9 @@ int cgroup_set_value_int64(struct cgroup_controller *controller,
int i;
unsigned ret;
+ if (!controller)
+ return ECGINVAL;
+
for (i = 0; i < controller->index; i++) {
struct control_value *val = controller->values[i];
@@ -419,6 +449,9 @@ int cgroup_get_value_uint64(struct cgroup_controller *controller,
{
int i;
+ if (!controller)
+ return ECGINVAL;
+
for (i = 0; i < controller->index; i++) {
struct control_value *val = controller->values[i];
if (!strcmp(val->name, name)) {
@@ -439,6 +472,9 @@ int cgroup_set_value_uint64(struct cgroup_controller *controller,
int i;
unsigned ret;
+ if (!controller)
+ return ECGINVAL;
+
for (i = 0; i < controller->index; i++) {
struct control_value *val = controller->values[i];
@@ -461,6 +497,9 @@ int cgroup_get_value_bool(struct cgroup_controller *controller,
{
int i;
+ if (!controller)
+ return ECGINVAL;
+
for (i = 0; i < controller->index; i++) {
struct control_value *val = controller->values[i];
@@ -487,6 +526,9 @@ int cgroup_set_value_bool(struct cgroup_controller *controller,
int i;
unsigned ret;
+ if (!controller)
+ return ECGINVAL;
+
for (i = 0; i < controller->index; i++) {
struct control_value *val = controller->values[i];