diff options
| author | Prashant Kamble <[email protected]> | 2026-05-18 11:38:44 +0530 |
|---|---|---|
| committer | Neil Armstrong <[email protected]> | 2026-05-20 09:44:37 +0200 |
| commit | d6eb327828a384c3bf325de05633a77f66688f53 (patch) | |
| tree | f8c57dfff9b1d0f1e19e959ba5c2c0cfe497d8fc | |
| parent | 49f8b8de4e6fa0aeb6c5eabec149b2537e94618b (diff) | |
nvme: fix command ID wraparound handling
nvme_get_cmd_id() returns 0 after cmdid reaches USHRT_MAX,
but fails to reset cmdid itself. As a result, all subsequent
calls keep returning 0 indefinitely.
Reset cmdid when wraparound occurs so command IDs continue
incrementing correctly.
Signed-off-by: Prashant Kamble <[email protected]>
Reviewed-by: Neil Armstrong <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Neil Armstrong <[email protected]>
| -rw-r--r-- | drivers/nvme/nvme.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/nvme/nvme.c b/drivers/nvme/nvme.c index 2b14437f69c..4f9473367d3 100644 --- a/drivers/nvme/nvme.c +++ b/drivers/nvme/nvme.c @@ -112,7 +112,10 @@ static __le16 nvme_get_cmd_id(void) { static unsigned short cmdid; - return cpu_to_le16((cmdid < USHRT_MAX) ? cmdid++ : 0); + if (cmdid >= USHRT_MAX) + cmdid = 0; + + return cpu_to_le16(cmdid++); } static u16 nvme_read_completion_status(struct nvme_queue *nvmeq, u16 index) |
