Skip to content

Commit

Permalink
kselftest/arm64: fix a memleak in zt_regs_run()
Browse files Browse the repository at this point in the history
If memcmp() does not return 0, "zeros" need to be freed to prevent memleak

Signed-off-by: Ding Xiang <dingxiang@cmss.chinamobile.com>
Link: https://lore.kernel.org/r/20230815074915.245528-1-dingxiang@cmss.chinamobile.com
Signed-off-by: Will Deacon <will@kernel.org>
  • Loading branch information
Ding Xiang authored and willdeacon committed Aug 16, 2023
1 parent 358b763 commit 46862da
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions tools/testing/selftests/arm64/signal/testcases/zt_regs.c
Expand Up @@ -65,6 +65,7 @@ int zt_regs_run(struct tdescr *td, siginfo_t *si, ucontext_t *uc)
if (memcmp(zeros, (char *)zt + ZT_SIG_REGS_OFFSET,
ZT_SIG_REGS_SIZE(zt->nregs)) != 0) {
fprintf(stderr, "ZT data invalid\n");
free(zeros);
return 1;
}

Expand Down

0 comments on commit 46862da

Please sign in to comment.