From f33ff18431e8ac01519bb1b3d48ddc2f2f59a2e4 Mon Sep 17 00:00:00 2001 From: Patrick Farrell Date: Fri, 25 Apr 2025 18:12:13 -0400 Subject: [PATCH] LU-10765 hsm: fix source_fd type in hsm_copyaction_private The source_fd field in struct hsm_copyaction_private was defined as __u32 (unsigned), but was being used with -1 to indicate an invalid file descriptor. This mismatch caused the error handling code to incorrectly check if source_fd < 0, which is impossible for an unsigned value, potentially leading to file descriptor leaks. Change the type of source_fd from __u32 to __s32 to match how it's used and to be consistent with data_fd which is already __s32. Test-Parameters: trivial Signed-off-by: Patrick Farrell Change-Id: I41d74642d9906075ec7eda670e4c390d55fed297 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/58980 Reviewed-by: Andreas Dilger Reviewed-by: Timothy Day Reviewed-by: Oleg Drokin Tested-by: jenkins Tested-by: Maloo --- lustre/utils/liblustreapi_hsm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lustre/utils/liblustreapi_hsm.c b/lustre/utils/liblustreapi_hsm.c index 5726730..619b10e 100644 --- a/lustre/utils/liblustreapi_hsm.c +++ b/lustre/utils/liblustreapi_hsm.c @@ -77,7 +77,7 @@ struct hsm_copytool_private { #define CP_PRIV_MAGIC 0x19880429 struct hsm_copyaction_private { __u32 magic; - __u32 source_fd; + __s32 source_fd; __s32 data_fd; const struct hsm_copytool_private *ct_priv; struct hsm_copy copy; -- 1.8.3.1