libmultipath: prevent memory leak in alloc_path_with_pathinfo() if pp_ptr is NULL
authorMauricio Faria de Oliveira <mauricfo@linux.vnet.ibm.com>
Wed, 14 Dec 2016 13:05:29 +0000 (11:05 -0200)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Wed, 14 Dec 2016 18:38:08 +0000 (19:38 +0100)
In alloc_path_with_pathinfo(), if the 'pp_ptr' argument is NULL
(which is acceptable and checked in the function in two places)
the 'pp' pointer is lost as it is not referenced anywhere else;
thus the memory allocated for it is leaked.

So, call free_path() in the case 'pp_ptr' is NULL too.

Signed-off-by: Mauricio Faria de Oliveira <mauricfo@linux.vnet.ibm.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
libmultipath/discovery.c

index 7b5b434..3c5c808 100644 (file)
@@ -58,7 +58,7 @@ alloc_path_with_pathinfo (struct config *conf, struct udev_device *udevice,
                err = pathinfo(pp, conf, flag | DI_BLACKLIST);
        }
 
-       if (err)
+       if (err || !pp_ptr)
                free_path(pp);
        else if (pp_ptr)
                *pp_ptr = pp;