Whamcloud - gitweb
LU-17000 obdclass: Initialize var 'bufsize' before using 91/55291/2
authorArshad Hussain <arshad.hussain@aeoncomputing.com>
Mon, 3 Jun 2024 10:01:04 +0000 (06:01 -0400)
committerOleg Drokin <green@whamcloud.com>
Mon, 10 Jun 2024 06:15:03 +0000 (06:15 +0000)
This patch initialize variable bufsize before using. This is because
bufsize is left uninitialized if obd_page_dif_generate_buffer() calls
fails. Once bufsize is initialize calling cfs_crypto_hash_final()
becomes safe.

Test-Parameters: trivial
CoverityID: 397224 ("Uninitialized scalar variable")
Signed-off-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Change-Id: I933cc3746d107acb308bd0060b7648a82410711c
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/55291
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Li Dongyang <dongyangli@ddn.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/obdclass/integrity.c

index 81b9d11..54906b8 100644 (file)
@@ -90,7 +90,7 @@ static int __obd_t10_performance_test(const char *obd_name,
        unsigned char cfs_alg = cksum_obd2cfs(OBD_CKSUM_T10_TOP);
        struct ahash_request *req;
        obd_dif_csum_fn *fn = NULL;
-       unsigned int bufsize;
+       unsigned int bufsize = 0;
        unsigned char *buffer;
        struct page *__page;
        __be16 *guard_start;
@@ -123,8 +123,7 @@ static int __obd_t10_performance_test(const char *obd_name,
        guard_start = (__be16 *)buffer;
        guard_number = PAGE_SIZE / sizeof(*guard_start);
        for (i = 0; i < repeat_number; i++) {
-               /*
-                * The left guard number should be able to hold checksums of a
+               /* The left guard number should be able to hold checksums of a
                 * whole page
                 */
                rc = obd_page_dif_generate_buffer(obd_name, data_page, 0,