Whamcloud - gitweb
LU-10765 hsm: fix source_fd type in hsm_copyaction_private 80/58980/3
authorPatrick Farrell <pfarrell@whamcloud.com>
Fri, 25 Apr 2025 22:12:13 +0000 (18:12 -0400)
committerOleg Drokin <green@whamcloud.com>
Wed, 7 May 2025 21:14:07 +0000 (21:14 +0000)
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 <pfarrell@whamcloud.com>
Change-Id: I41d74642d9906075ec7eda670e4c390d55fed297
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/58980
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Timothy Day <timday@amazon.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/utils/liblustreapi_hsm.c

index 5726730..619b10e 100644 (file)
@@ -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;