[PATCH] nvmet: preserve ANA log page copy errors

From: Sreeraj S Kurup

Date: Sat Oct 31 2026 - 04:36:19 EST


Do not overwrite an error returned while copying ANA
group descriptors with the result of copying the ANA
log page header.

Initialize the status to success before processing
ANA groups and copy the header only if all group
descriptor copies succeed. This ensures that failures
during descriptor copying are correctly reported to
the host.

Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@xxxxxxxxx>
---
drivers/nvme/target/admin-cmd.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index 26028be8fe4d..2bcb6d3de9ec 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -543,7 +543,7 @@ static void nvmet_execute_get_log_page_ana(struct nvmet_req *req)
u16 ngrps = 0;
u16 status;

- status = NVME_SC_INTERNAL;
+ status = NVME_SC_SUCCESS;
desc = kmalloc_flex(*desc, nsids, NVMET_MAX_NAMESPACES);
if (!desc)
goto out;
@@ -572,7 +572,8 @@ static void nvmet_execute_get_log_page_ana(struct nvmet_req *req)
kfree(desc);

/* copy the header last once we know the number of groups */
- status = nvmet_copy_to_sgl(req, 0, &hdr, sizeof(hdr));
+ if (!status)
+ status = nvmet_copy_to_sgl(req, 0, &hdr, sizeof(hdr));
out:
nvmet_req_complete(req, status);
}
--
2.55.0