md_monitor: Check device name length

The device name is copied into a fixed buffer, so we should be
checking the length of the string before copying.
Spotted by coverity.

Signed-off-by: Hannes Reinecke <hare@suse.de>
md_monitor: Use correct type for read() return value

read() returns -1 on error, so we need to use 'ssize_t' here.
Spotted by coverity.

Signed-off-by: Hannes Reinecke <hare@suse.de>
md_monitor: Lock access to ->running when starting threads

When starting threads we always should lock access to ->running
as there might be stale threads running, and we should yield the
lock to give them time to react.
Spotted by coverity.

Signed-off-by: Hannes Reinecke <hare@suse.de>
md_monitor: Fixup missing unlock()

An unlock was missing in an error path.
Spotted by coverity.

Signed-off-by: Hannes Reinecke <hare@suse.de>
md_monitor: Remove call to gettimeofday

Pointless, as the time is never evaluated.
Spotted by coverity.

Signed-off-by: Hannes Reinecke <hare@suse.de>
md_monitor: Check return values from setsockopts()

Spotted by coverity.

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