Patches from upstream

37e3103, d4ac69e and 9bf9d7e are fixes for issues found with Coverity scan.
c5474c2 Reply to disconnection from association and configuration states
e2eb64 and e9beea6 Make sure the device is up and running before enabling it