[dm-devel] [PATCH 20/78] Make checker_put() and prio_put() idempotent
Hannes Reinecke
hare at suse.de
Mon Mar 16 12:36:07 UTC 2015
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 at suse.de>
---
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
More information about the dm-devel
mailing list