[PATCH 20/78] Make checker_put() and prio_put() idempotent

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



checker_put() and prio_put() should check whether an instance
was selected prior to dropping a reference to it.
Otherwise they'll be dropping a reference which they haven't
increased in the first place.

Signed-off-by: Hannes Reinecke <hare@xxxxxxx>
---
 libmultipath/checkers.c | 2 +-
 libmultipath/prio.c     | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/libmultipath/checkers.c b/libmultipath/checkers.c
index 1dd5525..ef1d099 100644
--- a/libmultipath/checkers.c
+++ b/libmultipath/checkers.c
@@ -195,7 +195,7 @@ void checker_put (struct checker * dst)
 {
 	struct checker * src;
 
-	if (!dst)
+	if (!dst || !dst->check)
 		return;
 	src = checker_lookup(dst->name);
 	if (dst->free)
diff --git a/libmultipath/prio.c b/libmultipath/prio.c
index 6ee0b9c..ab8eca9 100644
--- a/libmultipath/prio.c
+++ b/libmultipath/prio.c
@@ -132,7 +132,7 @@ int prio_getprio (struct prio * p, struct path * pp)
 
 int prio_selected (struct prio * p)
 {
-	if (!p || !p->getprio)
+	if (!p)
 		return 0;
 	return (p->getprio) ? 1 : 0;
 }
@@ -169,7 +169,7 @@ void prio_put (struct prio * dst)
 {
 	struct prio * src;
 
-	if (!dst)
+	if (!dst || !dst->getprio)
 		return;
 
 	src = prio_lookup(dst->name);
-- 
1.8.4.5

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel




[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux