All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] libmultipath: prevent memory leak in alloc_path_with_pathinfo() if pp_ptr is NULL
@ 2016-12-13 18:27 Mauricio Faria de Oliveira
  2016-12-13 18:27 ` [PATCH v2 2/2] multipathd: skip spurious event message for blacklisted paths Mauricio Faria de Oliveira
  0 siblings, 1 reply; 6+ messages in thread
From: Mauricio Faria de Oliveira @ 2016-12-13 18:27 UTC (permalink / raw)
  To: dm-devel, bmarzins, christophe.varoqui

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>
---
 libmultipath/discovery.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
index 7b5b4344b2a1..3c5c808436b2 100644
--- a/libmultipath/discovery.c
+++ b/libmultipath/discovery.c
@@ -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;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-12-20 17:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-13 18:27 [PATCH v2 1/2] libmultipath: prevent memory leak in alloc_path_with_pathinfo() if pp_ptr is NULL Mauricio Faria de Oliveira
2016-12-13 18:27 ` [PATCH v2 2/2] multipathd: skip spurious event message for blacklisted paths Mauricio Faria de Oliveira
2016-12-13 21:50   ` Benjamin Marzinski
2016-12-13 23:53     ` Mauricio Faria de Oliveira
2016-12-14 12:53     ` Martin Wilck
2016-12-20 17:00       ` Benjamin Marzinski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.