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>
diff --git a/tools/iio/iio_event_monitor.c b/tools/iio/iio_event_monitor.c
index 578390d..1374374 100644
--- a/tools/iio/iio_event_monitor.c
+++ b/tools/iio/iio_event_monitor.c
@@ -265,6 +265,8 @@
 		/* If we can't find a IIO device by name assume device_name is a
 		   IIO chrdev */
 		chrdev_name = strdup(device_name);
+		if (!chrdev_name)
+			return -ENOMEM;
 	}
 
 	fd = open(chrdev_name, 0);