All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: Christophe Varoqui <christophe.varoqui@gmail.com>
Cc: Hannes Reinecke <hare@suse.com>, dm-devel@redhat.com
Subject: [PATCH 04/39] libmultipath: free pathgroup in group_by_prio()
Date: Thu, 16 Jun 2016 11:47:10 +0200	[thread overview]
Message-ID: <1466070465-1021-5-git-send-email-hare@suse.de> (raw)
In-Reply-To: <1466070465-1021-1-git-send-email-hare@suse.de>

If we encounter an error when storing the pathgroup or paths
the pathgroup is never deallocated.
Found by coverity.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 libmultipath/pgpolicies.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/libmultipath/pgpolicies.c b/libmultipath/pgpolicies.c
index 2981d51..f440441 100644
--- a/libmultipath/pgpolicies.c
+++ b/libmultipath/pgpolicies.c
@@ -341,8 +341,10 @@ group_by_prio (struct multipath * mp)
 		if (!pgp)
 			goto out;
 
-		if (store_path(pgp->paths, VECTOR_SLOT(mp->paths, 0)))
-				goto out;
+		if (store_path(pgp->paths, VECTOR_SLOT(mp->paths, 0))) {
+			free_pathgroup(pgp, KEEP_PATHS);
+			goto out;
+		}
 
 		vector_del_slot(mp->paths, 0);
 
@@ -350,11 +352,15 @@ group_by_prio (struct multipath * mp)
 		 * Store the new path group into the vector.
 		 */
 		if (i < VECTOR_SIZE(mp->pg)) {
-			if (!vector_insert_slot(mp->pg, i, pgp))
+			if (!vector_insert_slot(mp->pg, i, pgp)) {
+				free_pathgroup(pgp, KEEP_PATHS);
 				goto out;
+			}
 		} else {
-			if (store_pathgroup(mp->pg, pgp))
+			if (store_pathgroup(mp->pg, pgp)) {
+				free_pathgroup(pgp, KEEP_PATHS);
 				goto out;
+			}
 		}
 
 		/*
-- 
2.6.6

  parent reply	other threads:[~2016-06-16  9:47 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-16  9:47 [PATCH 00/39] multipath: coverity fixes Hannes Reinecke
2016-06-16  9:47 ` [PATCH 01/39] multipathd: correctly free refwwid in cli_add_map() Hannes Reinecke
2016-06-16  9:47 ` [PATCH 02/39] libmultipath: fixup string copy and comparison Hannes Reinecke
2016-06-16  9:47 ` [PATCH 03/39] libmultipath: fixup uninitialized return value in dm_reassign_table() Hannes Reinecke
2016-06-16  9:47 ` Hannes Reinecke [this message]
2016-06-16  9:47 ` [PATCH 05/39] libmultipath: memory leak in remove_feature() Hannes Reinecke
2016-06-16  9:47 ` [PATCH 06/39] libmultipath: memory leak in add_map_without_path() Hannes Reinecke
2016-06-16  9:47 ` [PATCH 07/39] libmultipath: missing NULL check in set_pgfailback() Hannes Reinecke
2016-06-16  9:47 ` [PATCH 08/39] libmultipath: remove stale references to fd_ep in uevent_listen() Hannes Reinecke
2016-06-16  9:47 ` [PATCH 09/39] libmultipath/devmapper.c: Remove unused 'next' argument Hannes Reinecke
2016-06-16  9:47 ` [PATCH 10/39] libmultipath/alias.c: check return value from strchr() Hannes Reinecke
2016-06-16  9:47 ` [PATCH 11/39] libmultipath/devmapper.c: check for errors from sscanf() Hannes Reinecke
2016-06-16  9:47 ` [PATCH 12/39] libmultipath/uevent.c: handle errors from setsockopt() Hannes Reinecke
2016-06-16  9:47 ` [PATCH 13/39] libmultipath/discovery.c: handle errors from sscanf() Hannes Reinecke
2016-06-16  9:47 ` [PATCH 14/39] libmultipath: drop unused variable 'diop' in libsg.c Hannes Reinecke
2016-06-16  9:47 ` [PATCH 15/39] libmultipath: use fstat() when reading sysfs attributes Hannes Reinecke
2016-06-16  9:47 ` [PATCH 16/39] libmultipath: fixup possible buffer overflow in alua_rtpg.c Hannes Reinecke
2016-06-16  9:47 ` [PATCH 17/39] libmultipath: memory leak in iet.c Hannes Reinecke
2016-06-16  9:47 ` [PATCH 18/39] libmpathcmd: limit size of the CLI buffer Hannes Reinecke
2016-06-16  9:47 ` [PATCH 19/39] libmpathpersist: Fix possible overrun in devt2devname() Hannes Reinecke
2016-06-16  9:47 ` [PATCH 20/39] libmpathpersist: memory leak in mpath_persistent_reserve_(in, out)() Hannes Reinecke
2016-06-16  9:47 ` [PATCH 21/39] libmpathpersist: Pass sensebuffer as pointer Hannes Reinecke
2016-06-16  9:47 ` [PATCH 22/39] libmpathpersist: Handle send error Hannes Reinecke
2016-06-16  9:47 ` [PATCH 23/39] libmultipath: missing break in hds prioritizer Hannes Reinecke
2016-06-16  9:47 ` [PATCH 24/39] kpartx: fixup fd leakage in lopart.c Hannes Reinecke
2016-06-16  9:47 ` [PATCH 25/39] kpartx: Memory leak in get_hotplug_device() Hannes Reinecke
2016-06-16  9:47 ` [PATCH 26/39] kpartx: fixup filedescriptor leak in set_loop() Hannes Reinecke
2016-06-16  9:47 ` [PATCH 27/39] kpartx: do not use 'const' for mapname in get_hotplug_device() Hannes Reinecke
2016-06-16  9:47 ` [PATCH 28/39] kpartx: Handle errors from lseek() Hannes Reinecke
2016-06-16  9:47 ` [PATCH 29/39] kpartx/devmapper.c: Remove unused 'next' argument Hannes Reinecke
2016-06-16  9:47 ` [PATCH 30/39] kpartx: use fstat() when reading sysfs attributes Hannes Reinecke
2016-06-16  9:47 ` [PATCH 31/39] kpartx/lopart.c: use fstat() when reading device nodes Hannes Reinecke
2016-06-16  9:47 ` [PATCH 32/39] libmultipath/sysfs.c: always terminate value from sysfs_attr_get_value() Hannes Reinecke
2016-06-16  9:47 ` [PATCH 33/39] multipathd: missing mpath_disconnect() in uxclnt() Hannes Reinecke
2016-06-16  9:47 ` [PATCH 34/39] multipathd: pid fd resource leak Hannes Reinecke
2016-06-16  9:47 ` [PATCH 35/39] libmultipath: mark return value from dup() as unused Hannes Reinecke
2016-06-16  9:47 ` [PATCH 36/39] libmultipath: Ignore errors from fcntl() in directio.c Hannes Reinecke
2016-06-16  9:47 ` [PATCH 37/39] libmultipath: add spin_lock in tur.c Hannes Reinecke
2016-06-16  9:47 ` [PATCH 38/39] libmultipath/devmapper.c: fixup possible buffer overflow Hannes Reinecke
2016-06-16  9:47 ` [PATCH 39/39] libmultipath/discovery.c: Fixup possible range overflow Hannes Reinecke
2016-06-20  7:09 ` [PATCH 00/39] multipath: coverity fixes Hannes Reinecke
2016-06-20  7:32   ` Christophe Varoqui

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1466070465-1021-5-git-send-email-hare@suse.de \
    --to=hare@suse.de \
    --cc=christophe.varoqui@gmail.com \
    --cc=dm-devel@redhat.com \
    --cc=hare@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.