sw_sync: Fix error paths

Check the return value of get_unused_fd to make sure a valid
file descriptor is returned.

Make sure to call put_unused_fd even if an error occurs before
the fd can be used.

Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>
Change-Id: Ibbf55caebc2f8ee6a03f298eb0ae0189c7d10b5c