nvme: nvme-fc: Fix nvme_fc_create_hw_io_queues() queue deletion in error path
Subsystems (2)
PATCH 1/1 nvme: nvme-fc: Fix nvme_fc_create_hw_io_queues() queue deletion in error path
nvme_fc_create_hw_io_queues() will call __nvme_fc_delete_hw_queue() for the last queue on which __nvme_fc_create_hw_queue() reported an error when deleting all the io queues if they cannot all be created. This is incorrect since the last queue did not actually get created.
The most recent change to this code was commit 17a1ec08ce70 ("nvme/fc: simplify error handling of nvme_fc_create_hw_io_queues") which moved the cleanup to thedelete_queues: label and changed the loop bounds, however the code was not correct prior to this change in a different way. The original commit e399441de911 ("nvme-fabrics: Add host support for FC transport") had a different error which called __nvme_fc_delete_hw_queue() on queue index 0 which is used for the admin queue.
Fix this by correcting the initial loop index when deleting the io queues.
--- drivers/nvme/host/fc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/fc.c +1 -1
@@ -2318,7 +2318,7 @@ nvme_fc_create_hw_io_queues(struct nvme_fc_ctrl *ctrl, u16 qsize)return 0 ; delete_queues: -for (; i >0 ; i--) +for (--i; i >0 ; i--)__nvme_fc_delete_hw_queue (ctrl, &ctrl->queues[i], i);return ret; }
Signature · 1 line
2.52.0
Regards,
Justin
Quoted 39 lines · Ewan D. Milne
nvme_fc_create_hw_io_queues()will call__nvme_fc_delete_hw_queue()for the last queue on which__nvme_fc_create_hw_queue()reported an error when deleting all the io queues if they cannot all be created. This is incorrect since the last queue did not actually get created.The most recent change to this code was commit
17a1ec08ce70("nvme/fc: simplify error handling ofnvme_fc_create_hw_io_queues") which moved the cleanup to thedelete_queues: label and changed the loop bounds, however the code was not correct prior to this change in a different way. The original commite399441de911("nvme-fabrics: Add host support for FC transport") had a different error which called__nvme_fc_delete_hw_queue()on queue index 0 which is used for the admin queue.Fix this by correcting the initial loop index when deleting the io queues.
Fixes 17a1ec08ce70 ("nvme/fc: simplify error handling of nvme_fc_create_hw_io_queues")Fixes e399441de911 ("nvme-fabrics: Add host support for FC transport")Assisted-by Claude:claude-opus-4-6Signed-off-by Ewan D. Milne <[email protected]>--- drivers/nvme/host/fc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/nvme/host/fc.c +1
-2@@ -2318,7 +2318,7 @@ nvme_fc_create_hw_io_queues(struct nvme_fc_ctrl *ctrl, u16 qsize)return 0 ; delete_queues: -for (; i >0 ; i--) +for (--i; i >0 ; i--)__nvme_fc_delete_hw_queue (ctrl, &ctrl->queues[i], i);return ret; } --
Quoted 3 lines
2.52.0
Gentle ping for reviews.
-Ewan
Laurence Oberman
Reviewed-byQuoted 61 lines · Ewan Milne
Quoted 46 lines · Ewan D. Milne
nvme_fc_create_hw_io_queues()will call__nvme_fc_delete_hw_queue()for the
last queue on which__nvme_fc_create_hw_queue()reported an error when deleting
all the io queues if they cannot all be created. This is incorrect since the
last queue did not actually get created.The most recent change to this code was commit
17a1ec08ce70("nvme/fc: simplify
error handling ofnvme_fc_create_hw_io_queues") which moved the cleanup to thedelete_queues: label and changed the loop bounds, however the code was not
correct prior to this change in a different way. The original commite399441de911("nvme-fabrics: Add host support for FC transport") had a
different error which called__nvme_fc_delete_hw_queue()on queue index 0 which
is used for the admin queue.Fix this by correcting the initial loop index when deleting the io queues.
Fixes 17a1ec08ce70 ("nvme/fc: simplify error handling of
nvme_fc_create_hw_io_queues")Fixes e399441de911 ("nvme-fabrics: Add host support for FCtransport")
Assisted-by Claude:claude-opus-4-6Signed-off-by Ewan D. Milne <[email protected]>---
drivers/nvme/host/fc.c | 2 +-1 file changed, 1 insertion(+), 1 deletion(-)drivers/nvme/host/fc.c +0
-0@@ -2318,7 +2318,7 @@ nvme_fc_create_hw_io_queues(struct nvme_fc_ctrl *ctrl, u16 qsize) return 0;delete_queues:
Quoted 10 lines
- for (; i > 0; i--)
+ for (--i; i > 0; i--)__nvme_fc_delete_hw_queue(ctrl, &ctrl->queues[i], i);
return ret;
}
--
2.52.0Gentle ping for reviews.
Quoted 2 lines
-Ewan
Looks good to me, loop index is corrected.
Quoted 29 lines · Ewan D. Milne
nvme_fc_create_hw_io_queues()will call__nvme_fc_delete_hw_queue()for the last queue on which__nvme_fc_create_hw_queue()reported an error when deleting all the io queues if they cannot all be created. This is incorrect since the last queue did not actually get created.The most recent change to this code was commit
17a1ec08ce70("nvme/fc: simplify error handling ofnvme_fc_create_hw_io_queues") which moved the cleanup to thedelete_queues: label and changed the loop bounds, however the code was not correct prior to this change in a different way. The original commite399441de911("nvme-fabrics: Add host support for FC transport") had a different error which called__nvme_fc_delete_hw_queue()on queue index 0 which is used for the admin queue.Fix this by correcting the initial loop index when deleting the io queues.
Fixes 17a1ec08ce70 ("nvme/fc: simplify error handling of nvme_fc_create_hw_io_queues")Fixes e399441de911 ("nvme-fabrics: Add host support for FC transport")Assisted-by Claude:claude-opus-4-6Signed-off-by Ewan D. Milne <[email protected]>--- drivers/nvme/host/fc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/nvme/host/fc.c +0
-0
drivers/nvme/host/fc.c nvme_fc_create_hw_io_queues(struct nvme_fc_ctrl *ctrl, u16 qsize) · line 2324
Quoted 8 lines
drivers/nvme/host/fc.c +1
-1@@ -2318,7 +2318,7 @@ nvme_fc_create_hw_io_queues(struct nvme_fc_ctrl *ctrl, u16 qsize)return 0 ; delete_queues: -for (; i >0 ; i--) +for (--i; i >0 ; i--)__nvme_fc_delete_hw_queue (ctrl, &ctrl->queues[i], i);return ret; }
Looks ok to me
Quoted 5 lines · Ewan D. Milne
nvme_fc_create_hw_io_queues()will call__nvme_fc_delete_hw_queue()for the last queue on which__nvme_fc_create_hw_queue()reported an error when deleting all the io queues if they cannot all be created. This is incorrect since the last queue did not actually get created.
Quoted 7 lines
The most recent change to this code was commit
17a1ec08ce70("nvme/fc: simplify error handling ofnvme_fc_create_hw_io_queues") which moved the cleanup to thedelete_queues: label and changed the loop bounds, however the code was not correct prior to this change in a different way. The original commite399441de911("nvme-fabrics: Add host support for FC transport") had a different error which called__nvme_fc_delete_hw_queue()on queue index 0 which is used for the admin queue.
Thanks, applied to nvme-7.3. Sorry for letting this one get lost for a bit there.