fix fd leaking and deallocation freed resource

Change-Id: Ibee4d7000bce5bc8c2e45339d4d53a242569ae4e
2 files changed