From 4fc998320b51b1730326df5db470b2ca9c1da7c9 Mon Sep 17 00:00:00 2001 From: Arshad Hussain Date: Fri, 15 Sep 2023 11:24:46 +0530 Subject: [PATCH] LU-17000 coverity: Fix Resource Leak(1) This patch fixes Resource leak error reported by coverity run. CoverityID: 397493 ("Resource Leak"): liblustreapi_mirror.c CoverityID: 397494 ("Resource Leak"): lustre_rsync.c Test-Parameters: trivial fstype=zfs testlist=sanity,sanityn,conf-sanity Signed-off-by: Arshad Hussain Change-Id: I10e9fd0945cf13824c25faa62b4310796b09bade Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/52384 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Patrick Farrell Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- lustre/utils/liblustreapi_mirror.c | 4 +++- lustre/utils/lustre_rsync.c | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lustre/utils/liblustreapi_mirror.c b/lustre/utils/liblustreapi_mirror.c index 55d9132..b93c948 100644 --- a/lustre/utils/liblustreapi_mirror.c +++ b/lustre/utils/liblustreapi_mirror.c @@ -310,8 +310,10 @@ ssize_t llapi_mirror_copy_many(int fd, __u16 src, __u16 *dst, size_t count) continue; } } - if (!nr) + if (!nr) { + free(buf); return result; + } } while (!eof) { diff --git a/lustre/utils/lustre_rsync.c b/lustre/utils/lustre_rsync.c index 944ec2e..f1c9a00 100644 --- a/lustre/utils/lustre_rsync.c +++ b/lustre/utils/lustre_rsync.c @@ -1728,10 +1728,12 @@ int lr_replicate(void) rc = 0; out: - if (info) - free(info); + if (changelog_priv) + free(changelog_priv); if (ext) free(ext); + if (info) + free(info); return rc; } -- 1.8.3.1