Commit 2279cd9c authored by Keith Busch's avatar Keith Busch
Browse files

nvme: fix bio leak on mapping failure



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: d0d1d522 ("blk-map: provide the bdev to bio if one exists")
Reviewed-by: default avatarSagi Grimberg <sagi@grimberg.me>
Reviewed-by: default avatarJohn Garry <john.g.garry@oracle.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarKeith Busch <kbusch@kernel.org>
parent ce28b772
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -121,7 +121,6 @@ static int nvme_map_user_request(struct request *req, u64 ubuffer,
	struct block_device *bdev = ns ? ns->disk->part0 : NULL;
	bool supports_metadata = bdev && blk_get_integrity(bdev->bd_disk);
	bool has_metadata = meta_buffer && meta_len;
	struct bio *bio = NULL;
	int ret;

	if (has_metadata && !supports_metadata)
@@ -145,8 +144,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;
}