CachedAppOptimizer: fix fd leak.

errno isn't modified when a syscall returns successfully: this would
leak if errno was already non-zero before entering this function.

Bug: 172518739
Test: none
Change-Id: I38050863ceca226a9c2d143c85e0713c6a6fe511
Merged-In: I38050863ceca226a9c2d143c85e0713c6a6fe511
This commit is contained in:
Josh Gao
2021-02-22 17:57:06 -08:00
committed by Edgar Arriaga
parent a4ecb890df
commit 9a24046259

View File

@@ -86,7 +86,7 @@ static int compactMemory(const std::vector<Vma>& vmas, int pid, int madviseType)
int pidfd = syscall(__NR_pidfd_open, pid, 0); int pidfd = syscall(__NR_pidfd_open, pid, 0);
err = -errno; err = -errno;
if (err < 0) { if (pidfd < 0) {
// Skip compaction if failed to open pidfd with any error // Skip compaction if failed to open pidfd with any error
return err; return err;
} }