nvme/target/admin-cmd.c: Fix a bug in 'nvmet_execute_get_log_page_error'
Subsystems (2)
PATCH 1/1 nvme/target/admin-cmd.c: Fix a bug in 'nvmet_execute_get_log_page_error'
From: Amit <[email protected]>
ensure that nvmet_copy_to_sgl does not exceed data_len
Signed-off-by Amit <amit.engel at emc.com>
--- drivers/nvme/target/admin-cmd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/nvme/target/admin-cmd.c +2 -1
@@ -40,13 +40,14 @@ static void nvmet_execute_get_log_page_error(struct nvmet_req *req)u16 status =NVME_SC_SUCCESS ;unsigned long flags;off_t offset =0 ; +size_t num_of_sgl_slots = req->data_len/sizeof (struct nvme_error_slot );u64 slot;u64 i;spin_lock_irqsave (&ctrl->error_lock, flags); slot = ctrl->err_counter %NVMET_ERROR_LOG_SLOTS ; -for (i =0 ; i <NVMET_ERROR_LOG_SLOTS ; i++) { +for (i =0 ; i <NVMET_ERROR_LOG_SLOTS && i < num_of_sgl_slots; i++) { status =nvmet_copy_to_sgl (req, offset, &ctrl->slots[slot],sizeof (struct nvme_error_slot ));if (status)
Signature · 1 line
2.16.2
Sagi Grimberg
maintainerPATCH 1/1 nvme/target/admin-cmd.c: Fix a bug in 'nvmet_execute_get_log_page_error'
Quoted 15 lines
From: Amit <amit.engel at emc.com>
ensure that
nvmet_copy_to_sgldoes not exceeddata_lenSigned-off-by Amit <amit.engel at emc.com>--- drivers/nvme/target/admin-cmd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/nvme/target/admin-cmd.c +0
-0
drivers/nvme/target/admin-cmd.c static void nvmet_execute_get_log_page_error(struct nvmet_req *req) · line 43
Quoted 4 lines
drivers/nvme/target/admin-cmd.c +1
-0@@ -40,13 +40,14 @@ static void nvmet_execute_get_log_page_error(struct nvmet_req *req)u16 status =NVME_SC_SUCCESS ;unsigned long flags;off_t offset =0 ; +size_t num_of_sgl_slots = req->data_len/sizeof (struct nvme_error_slot );
This should be do_div.