Skip to contentSkip to conversation

multipathd: fix possible null deference in purge_disconnected code

PATCH In review Benjamin Marzinski 2 participants 2 messages Jan 28 Device mapper

lore
Share & tools
lore

Benjamin Marzinski

author maintainer
#0 lore raw

PATCH 1/1 multipathd: fix possible null deference in purge_disconnected code

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")
---
 multipathd/main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
multipathd/main.c +2 -1
index 05dd65e6..d87c7b12 100644
@@ -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));
Signature · 1 line
2.50.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Benjamin Marzinski

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")