lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230105214635.874609-1-trix@redhat.com>
Date:   Thu,  5 Jan 2023 16:46:35 -0500
From:   Tom Rix <trix@...hat.com>
To:     alim.akhtar@...sung.com, avri.altman@....com, bvanassche@....org,
        jejb@...ux.ibm.com, martin.petersen@...cle.com, nathan@...nel.org,
        ndesaulniers@...gle.com, beanhuo@...ron.com,
        Arthur.Simchaev@....com, stanley.chu@...iatek.com,
        j-young.choi@...sung.com, peter.wang@...iatek.com
Cc:     linux-scsi@...r.kernel.org, linux-kernel@...r.kernel.org,
        llvm@...ts.linux.dev, Tom Rix <trix@...hat.com>
Subject: [PATCH] scsi: ufs: core: initialize sg_cnt, sg_list

The clang build fails with
drivers/ufs/core/ufs_bsg.c:107:6: error: variable 'sg_cnt' is used
  uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
        if (dir != DMA_NONE) {
            ^~~~~~~~~~~~~~~
Similar for sg_list.

This is not an error because ufshcd_advanced_rpmb_req_handler() does a
similar check, but that check can be reduced if sg_list is initialized to NULL.
Initialize sg_cnt to silence its error.

Signed-off-by: Tom Rix <trix@...hat.com>
---
 drivers/ufs/core/ufs_bsg.c | 4 ++--
 drivers/ufs/core/ufshcd.c  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/ufs/core/ufs_bsg.c b/drivers/ufs/core/ufs_bsg.c
index 0044029bcf7b..0d38e7fa34cc 100644
--- a/drivers/ufs/core/ufs_bsg.c
+++ b/drivers/ufs/core/ufs_bsg.c
@@ -70,9 +70,9 @@ static int ufs_bsg_exec_advanced_rpmb_req(struct ufs_hba *hba, struct bsg_job *j
 	struct ufs_rpmb_reply *rpmb_reply = job->reply;
 	struct bsg_buffer *payload = NULL;
 	enum dma_data_direction dir;
-	struct scatterlist *sg_list;
+	struct scatterlist *sg_list = NULL;
 	int rpmb_req_type;
-	int sg_cnt;
+	int sg_cnt = 0;
 	int ret;
 	int data_len;
 
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index da81eafc19d5..6ed728885650 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -7051,7 +7051,7 @@ int ufshcd_advanced_rpmb_req_handler(struct ufs_hba *hba, struct utp_upiu_req *r
 	/* Copy EHS, starting with byte32, immediately after the CDB package */
 	memcpy(lrbp->ucd_req_ptr + 1, req_ehs, sizeof(*req_ehs));
 
-	if (dir != DMA_NONE && sg_list)
+	if (sg_list)
 		ufshcd_sgl_to_prdt(hba, lrbp, sg_cnt, sg_list);
 
 	memset(lrbp->ucd_rsp_ptr, 0, sizeof(struct utp_upiu_rsp));
-- 
2.27.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ