purge_disconnected only works on paths that are part of a multipath
device. However, get_new_state() is also run on uninitialized paths that
are not part of any multipath device, and the purge_disconnected code in
it was dereferencing pp->mpp, without checking if it was NULL. Fix that.

Fixes: 690550a1 ("multipathd: implement purge functionality for disconnected 
paths")
Signed-off-by: Benjamin Marzinski <[email protected]>
---
 multipathd/main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/multipathd/main.c b/multipathd/main.c
index 05dd65e6..d87c7b12 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -2518,7 +2518,8 @@ get_new_state(struct path *pp)
         * checker to trigger special handling before becoming PATH_DOWN.
         */
        if (newstate == PATH_DISCONNECTED) {
-               if (pp->mpp->purge_disconnected == PURGE_DISCONNECTED_ON &&
+               if (pp->mpp &&
+                   pp->mpp->purge_disconnected == PURGE_DISCONNECTED_ON &&
                    pp->disconnected == NOT_DISCONNECTED) {
                        condlog(2, "%s: mark (%s) path for purge", pp->dev,
                                checker_state_name(newstate));
-- 
2.50.1


Reply via email to