libmultipath: fix memory leaks from scandir() use
authorMartin Wilck <mwilck@suse.com>
Fri, 2 Nov 2018 12:21:06 +0000 (13:21 +0100)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Wed, 14 Nov 2018 07:21:14 +0000 (08:21 +0100)
commitb0e8a7456dd83cd0a5ecd1005e016656e785405f
tree8ca08e385d9f6b9135aee52bb19e5fd6f08ca2ac
parentccb1808b9fbc416b2eeabb2a5faf4976c87681b7
libmultipath: fix memory leaks from scandir() use

scandir() users must not only free the resulting dirent* array,
but also every member. Add a cleanup function, and fix the
existing users of scandir() in libmultipath.

Add a small helper macro for casting function pointers to the
type pthread_cleanup_push() expects.

Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Martin Wilck <mwilck@suse.com>
libmultipath/config.c
libmultipath/foreign.c
libmultipath/foreign/nvme.c
libmultipath/sysfs.c
libmultipath/util.c
libmultipath/util.h