diff options
author | James Smart <jsmart2021@gmail.com> | 2017-09-21 08:13:49 -0700 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2017-09-25 12:42:11 -0600 |
commit | 8cbd96a6285e8eb65232b5afd3e8d9418453a61c (patch) | |
tree | b152e6d500ae8aa28866a80f9dd4d6dd893d11f0 /drivers/nvme | |
parent | f5c156c4c29a3d87176dd6e5c099388e187ec29b (diff) | |
download | op-kernel-dev-8cbd96a6285e8eb65232b5afd3e8d9418453a61c.zip op-kernel-dev-8cbd96a6285e8eb65232b5afd3e8d9418453a61c.tar.gz |
nvme: fix sqhd reference when admin queue connect fails
Fix bug in sqhd patch.
It wasn't the sq that was at risk. In the case where the admin queue
connect command fails, the sq->size field is not set. Therefore, this
becomes a divide by zero error.
Add a quick check to bypass under this failure condition.
Signed-off-by: James Smart <james.smart@broadcom.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/nvme')
-rw-r--r-- | drivers/nvme/target/core.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c index c2a768a..1b208be 100644 --- a/drivers/nvme/target/core.c +++ b/drivers/nvme/target/core.c @@ -390,7 +390,8 @@ static void __nvmet_req_complete(struct nvmet_req *req, u16 status) if (status) nvmet_set_status(req, status); - req->sq->sqhd = (req->sq->sqhd + 1) % req->sq->size; + if (req->sq->size) + req->sq->sqhd = (req->sq->sqhd + 1) % req->sq->size; req->rsp->sq_head = cpu_to_le16(req->sq->sqhd); req->rsp->sq_id = cpu_to_le16(req->sq->qid); req->rsp->command_id = req->cmd->common.command_id; |