]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
nvme: avoid double free special payload
authorChunguang Xu <chunguang.xu@shopee.com>
Tue, 11 Jun 2024 10:02:08 +0000 (18:02 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 2 May 2025 05:41:05 +0000 (07:41 +0200)
commit e5d574ab37f5f2e7937405613d9b1a724811e5ad upstream.

If a discard request needs to be retried, and that retry may fail before
a new special payload is added, a double free will result. Clear the
RQF_SPECIAL_LOAD when the request is cleaned.

Signed-off-by: Chunguang Xu <chunguang.xu@shopee.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Max Gurtovoy <mgurtovoy@nvidia.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
[Minor context change fixed]
Signed-off-by: Cliff Liu <donghua.liu@windriver.com>
Signed-off-by: He Zhe <Zhe.He@windriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/nvme/host/core.c

index 5f16fc9111a9fe665f0a0af04e22f820245c70b6..e63d3ca11cc9a26342a358a68b5e9906c6557f8f 100644 (file)
@@ -850,6 +850,7 @@ void nvme_cleanup_cmd(struct request *req)
                        clear_bit_unlock(0, &ns->ctrl->discard_page_busy);
                else
                        kfree(page_address(page) + req->special_vec.bv_offset);
+               req->rq_flags &= ~RQF_SPECIAL_PAYLOAD;
        }
 }
 EXPORT_SYMBOL_GPL(nvme_cleanup_cmd);