summaryrefslogtreecommitdiffstats
path: root/tools/iio/lsiio.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/iio/lsiio.c')
-rw-r--r--tools/iio/lsiio.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/tools/iio/lsiio.c b/tools/iio/lsiio.c
index 65a2385e2a78..daa6c5312d66 100644
--- a/tools/iio/lsiio.c
+++ b/tools/iio/lsiio.c
@@ -107,7 +107,12 @@ static void dump_devices(void)
if (check_prefix(ent->d_name, type_device)) {
char *dev_dir_name;
- asprintf(&dev_dir_name, "%s%s", iio_dir, ent->d_name);
+ if (asprintf(&dev_dir_name, "%s%s", iio_dir,
+ ent->d_name) < 0) {
+ printf("Memory allocation failed\n");
+ goto error_close_dir;
+ }
+
dump_one_device(dev_dir_name);
free(dev_dir_name);
if (verblevel >= VERBLEVEL_SENSORS)
@@ -119,11 +124,17 @@ static void dump_devices(void)
if (check_prefix(ent->d_name, type_trigger)) {
char *dev_dir_name;
- asprintf(&dev_dir_name, "%s%s", iio_dir, ent->d_name);
+ if (asprintf(&dev_dir_name, "%s%s", iio_dir,
+ ent->d_name) < 0) {
+ printf("Memory allocation failed\n");
+ goto error_close_dir;
+ }
+
dump_one_trigger(dev_dir_name);
free(dev_dir_name);
}
}
+error_close_dir:
closedir(dp);
}