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
[ Upstream commit 46862da ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Ding Xiang authored and gregkh committed Sep 23, 2023
1 parent ef0d6a9 commit 8f59a9c
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 8f59a9c

Please sign in to comment.