Samsung posts first net loss, but handset sales are up