summaryrefslogtreecommitdiffstats
path: root/tools/iio/iio_utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/iio/iio_utils.c')
-rw-r--r--tools/iio/iio_utils.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/tools/iio/iio_utils.c b/tools/iio/iio_utils.c
index 812153ff18c3..f0896f46847f 100644
--- a/tools/iio/iio_utils.c
+++ b/tools/iio/iio_utils.c
@@ -36,7 +36,7 @@ int iioutils_break_up_name(const char *full_name,
char *current;
char *w, *r;
char *working, *prefix = "";
- int i;
+ int i, ret;
for (i = 0; i < sizeof(iio_direction) / sizeof(iio_direction[0]); i++)
if (!strncmp(full_name, iio_direction[i],
@@ -46,6 +46,9 @@ int iioutils_break_up_name(const char *full_name,
}
current = strdup(full_name + strlen(prefix) + 1);
+ if (!current)
+ return -ENOMEM;
+
working = strtok(current, "_\0");
w = working;
@@ -59,10 +62,10 @@ int iioutils_break_up_name(const char *full_name,
r++;
}
*w = '\0';
- asprintf(generic_name, "%s_%s", prefix, working);
+ ret = asprintf(generic_name, "%s_%s", prefix, working);
free(current);
- return 0;
+ return (ret == -1) ? -ENOMEM : 0;
}
/**
OpenPOWER on IntegriCloud