public inbox for linux-nvme@lists.infradead.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: kernel test robot <lkp@intel.com>
Cc: Christoph Hellwig <hch@lst.de>,
	linux-nvme@lists.infradead.org,
	Alan Adamson <alan.adamson@oracle.com>
Subject: Re: [linux-nvme:nvme-5.19] BUILD SUCCESS WITH WARNING 4db675888cdb7b24812e289d7f90e7928dd400a3
Date: Thu, 30 Jun 2022 08:24:13 +0200	[thread overview]
Message-ID: <20220630062413.GA6635@lst.de> (raw)
In-Reply-To: <62bd3b92.UluA72FI79OFZKgS%lkp@intel.com>

On Thu, Jun 30, 2022 at 01:58:42PM +0800, kernel test robot wrote:
> tree/branch: git://git.infradead.org/nvme.git nvme-5.19
> branch HEAD: 4db675888cdb7b24812e289d7f90e7928dd400a3  nvmet: add a clear_ids attribute for passthru targets
> 
> Warning: (recently discovered and may have been fixed)
> 
> drivers/nvme/target/passthru.c:54:16: warning: variable 'csi_seen' is used uninitialized whenever 'for' loop exits because its condition is false [-Wsometimes-uninitialized]
> drivers/nvme/target/passthru.c:57:7: warning: variable 'csi_seen' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]

I ended up fixing this with the patch below.  Alan, let me know
if this works for you:

diff --git a/drivers/nvme/target/passthru.c b/drivers/nvme/target/passthru.c
index d71ed297ad16b..6f39a29828b12 100644
--- a/drivers/nvme/target/passthru.c
+++ b/drivers/nvme/target/passthru.c
@@ -33,10 +33,9 @@ void nvmet_passthrough_override_cap(struct nvmet_ctrl *ctrl)
 static u16 nvmet_passthru_override_id_descs(struct nvmet_req *req)
 {
 	struct nvmet_ctrl *ctrl = req->sq->ctrl;
-	struct nvme_ns_id_desc *cur;
 	u16 status = NVME_SC_SUCCESS;
 	int pos, len;
-	bool csi_seen;
+	bool csi_seen = false;
 	void *data;
 	u8 csi;
 
@@ -52,26 +51,25 @@ static u16 nvmet_passthru_override_id_descs(struct nvmet_req *req)
 		goto out_free;
 
 	for (pos = 0; pos < NVME_IDENTIFY_DATA_SIZE; pos += len) {
-		cur = data + pos;
+		struct nvme_ns_id_desc *cur = data + pos;
 
 		if (cur->nidl == 0)
 			break;
-		len = cur->nidl;
 		if (cur->nidt == NVME_NIDT_CSI) {
-			memcpy(&csi, data + pos + sizeof(struct nvme_ns_id_desc),
-			       NVME_NIDT_CSI_LEN);
-			csi_seen = 1;
+			memcpy(&csi, cur + 1, NVME_NIDT_CSI_LEN);
+			csi_seen = true;
 			break;
 		}
-		len += sizeof(struct nvme_ns_id_desc);
+		len = sizeof(struct nvme_ns_id_desc) + cur->nidl;
 	}
 
 	memset(data, 0, NVME_IDENTIFY_DATA_SIZE);
 	if (csi_seen) {
-		cur = data;
+		struct nvme_ns_id_desc *cur = data;
+
 		cur->nidt = NVME_NIDT_CSI;
 		cur->nidl = NVME_NIDT_CSI_LEN;
-		memcpy(data + sizeof(struct nvme_ns_id_desc), &csi,  NVME_NIDT_CSI_LEN);
+		memcpy(cur + 1, &csi, NVME_NIDT_CSI_LEN);
 	}
 	status = nvmet_copy_to_sgl(req, 0, data, NVME_IDENTIFY_DATA_SIZE);
 out_free:


  reply	other threads:[~2022-06-30  6:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-30  5:58 [linux-nvme:nvme-5.19] BUILD SUCCESS WITH WARNING 4db675888cdb7b24812e289d7f90e7928dd400a3 kernel test robot
2022-06-30  6:24 ` Christoph Hellwig [this message]
2022-06-30 16:54   ` Alan Adamson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220630062413.GA6635@lst.de \
    --to=hch@lst.de \
    --cc=alan.adamson@oracle.com \
    --cc=linux-nvme@lists.infradead.org \
    --cc=lkp@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox