Merge "sdm: Close fds only if they are valid"