Skip to contentSkip to conversation

nvme: fix bio leak on mapping failure

PATCH In review Keith Busch 4 participants 4 messages May 6 – May 10 NVMe

lore
Share & tools
lore
#0 lore raw

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")
---
 drivers/nvme/host/ioctl.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/nvme/host/ioctl.c +2 -3
index 39d6e69cbbe72..df2b7a66f6310 100644
@@ -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