multipathd: avoid null pointer dereference in LOG_MSG
authorMartin Wilck <mwilck@suse.de>
Wed, 13 Feb 2019 22:55:05 +0000 (16:55 -0600)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Thu, 14 Feb 2019 17:53:05 +0000 (18:53 +0100)
commit3b52a8ee0ab5d19a8bd7351597b6517bbbce387a
tree82a1f7bf1fcc7cbfc11c64f5c44f4e447cb39e1f
parent2df61104a9b8031d087598f3524658f298af1702
multipathd: avoid null pointer dereference in LOG_MSG

LOG_MSG() will dereference pp->mpp. Commit cb5ec664 added a call to
LOG_MSG() before the check for (!pp->mpp) in check_path.  This can cause
multipathd to crash.  LOG_MSG() should check the fields before dereferencing
them. Make checker_selected() an inline function to allow the compiler
to optimize away the usually redundant test "if (&checker->pp != NULL)".

Also, checker_message() should fail to a generic message if c->cls isn't
set (which means that a checker hasn't been selected).

Fixes: cb5ec664 (multipathd: check_path: improve logging for "unusable
                 path" case)
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Martin Wilck <mwilck@suse.com>
libmultipath/checkers.c
libmultipath/checkers.h
multipathd/main.c