[PATCH] nvme: initialize identify ns data to NULL

Tokunori Ikegami ikegami.t at gmail.com
Mon Mar 25 08:45:03 PDT 2024


Currently nvme_identify_ns() sets the data to NULL if failed.
Also the data is not freed if the function returned failure.
But correctly the data should be initialized to NULL.
So to make sure fix to initialize the data to NULL.

Signed-off-by: Tokunori Ikegami <ikegami.t at gmail.com>
---
 drivers/nvme/host/sysfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/nvme/host/sysfs.c b/drivers/nvme/host/sysfs.c
index 3c55f7edd181..4e996e10f46a 100644
--- a/drivers/nvme/host/sysfs.c
+++ b/drivers/nvme/host/sysfs.c
@@ -185,7 +185,7 @@ static DEVICE_ATTR_RO(metadata_bytes);
 
 static int ns_head_update_nuse(struct nvme_ns_head *head)
 {
-	struct nvme_id_ns *id;
+	struct nvme_id_ns *id = NULL;
 	struct nvme_ns *ns;
 	int srcu_idx, ret = -EWOULDBLOCK;
 
@@ -212,7 +212,7 @@ static int ns_head_update_nuse(struct nvme_ns_head *head)
 
 static int ns_update_nuse(struct nvme_ns *ns)
 {
-	struct nvme_id_ns *id;
+	struct nvme_id_ns *id = NULL;
 	int ret;
 
 	/* Avoid issuing commands too often by rate limiting the update. */
-- 
2.40.1




More information about the Linux-nvme mailing list