multipathd: fix possible null deference in purge_disconnected code
Benjamin Marzinski
maintainerPATCH 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")
Signed-off-by Benjamin Marzinski <[email protected]>
--- multipathd/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
multipathd/main.c +2 -1
@@ -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
Quoted 11 lines · Benjamin Marzinski
purge_disconnectedonly 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 thepurge_disconnectedcode in
it was dereferencingpp->mpp, without checking if it was NULL. Fix that.Fixes 690550a1 ("multipathd: implement purge functionality fordisconnected paths")
Signed-off-by Benjamin Marzinski <[email protected]>
Reviewed-by Martin Wilck <[email protected]>