nvme: fix bio leak on mapping failure
PATCH 1/1 nvme: fix bio leak on mapping failure
From: Keith Busch <[email protected]>
The local bio is always NULL, so we'd leak the bio if the integrity mapping failed. Just get it directly from the request.
Fixes d0d1d522316e91f ("blk-map: provide the bdev to bio if one exists")
Signed-off-by Keith Busch <[email protected]>
--- drivers/nvme/host/ioctl.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/nvme/host/ioctl.c +2 -3
@@ -122,7 +122,6 @@ static int nvme_map_user_request(struct request *req, u64 ubuffer,bool supports_metadata = bdev &&blk_get_integrity (bdev->bd_disk);struct nvme_ctrl *ctrl =nvme_req (req)->ctrl;bool has_metadata = meta_buffer && meta_len; -struct bio *bio =NULL ;int ret;if (has_metadata && !supports_metadata)
@@ -146,8 +145,8 @@ static int nvme_map_user_request(struct request *req, u64 ubuffer,return ret; out_unmap: -if (bio) -blk_rq_unmap_user (bio); +if (req->bio) +blk_rq_unmap_user (req->bio);return ret; }
Signature · 1 line
2.52.0
Looks good:
Reviewed-by Christoph Hellwig <[email protected]>
Quoted 8 lines · Keith Busch
From: Keith Busch<[email protected]>
The local bio is always NULL, so we'd leak the bio if the integrity mapping failed. Just get it directly from the request.
Fixes d0d1d522316e91f ("blk-map: provide the bdev to bio if one exists")Signed-off-by Keith Busch<[email protected]>---
FWIW:
Reviewed-by John Garry <[email protected]>
Reviewed-by Sagi Grimberg <[email protected]>