md_monitor: Fixup uninitialised variable

Spotted by coverity.

Signed-off-by: Hannes Reinecke <hare@suse.de>
md_monitor: Close cli_sock in case of error

Whenever there is an error during creation of the cli socket
we need to close it, otherwise we'll leak a socket.
Spotted by coverity.

Signed-off-by: Hannes Reinecke <hare@suse.de>
md_monitor: Terminate strings after reading from sysfs

Although we cannot read unterminated strings from sysfs we might
be reading strings which are larger than the buffer. So add
proper checking here to avoid silent buffer overflow.
Spotted by coverity.

Signed-off-by: Hannes Reinecke <hare@suse.de>
md_monitor: use MD name in lookup_md_alias()

When looking up a MD array it might be specified by either the
actual device node name or the MD array name, so we need to
check for both.

References: bnc#876830

Signed-off-by: Hannes Reinecke <hare@suse.de>