diff options
author | Hartmut Knaack <knaack.h@gmx.de> | 2015-05-31 14:40:02 +0200 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2015-05-31 19:21:10 +0100 |
commit | e9e45b43b8f06273d9b78f187042dff0bf5be0a5 (patch) | |
tree | 2e0bb238e6b234a12366c545e879b9b6646b9985 /tools/iio/lsiio.c | |
parent | 2156b179993e3d5b422976181ba17d91153313e1 (diff) | |
download | linux-e9e45b43b8f06273d9b78f187042dff0bf5be0a5.tar.bz2 |
tools:iio: catch errors in string allocation
This patch catches errors in string allocation in generic_buffer.c,
iio_event_monitor.c, iio_utils.c and lsiio.c.
Signed-off-by: Hartmut Knaack <knaack.h@gmx.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'tools/iio/lsiio.c')
-rw-r--r-- | tools/iio/lsiio.c | 15 |
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); } |