Skip to content

Commit 00817f0

Browse files
committed
nvme-ioctl: fix leaked requests on mapping error
All the callers assume nvme_map_user_request() frees the request on a failure. This wasn't happening on invalid metadata or io_uring command flags, so we've been leaking those requests. Fixes: 23fd22e ("nvme: wire up fixed buffer support for nvme passthrough") Fixes: 7c2fd76 ("nvme: fix metadata handling in nvme-passthrough") Reviewed-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Kanchan Joshi <joshi.k@samsung.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Keith Busch <kbusch@kernel.org>
1 parent 56cf7ef commit 00817f0

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

drivers/nvme/host/ioctl.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,10 @@ static int nvme_map_user_request(struct request *req, u64 ubuffer,
128128
if (!nvme_ctrl_sgl_supported(ctrl))
129129
dev_warn_once(ctrl->device, "using unchecked data buffer\n");
130130
if (has_metadata) {
131-
if (!supports_metadata)
132-
return -EINVAL;
131+
if (!supports_metadata) {
132+
ret = -EINVAL;
133+
goto out;
134+
}
133135
if (!nvme_ctrl_meta_sgl_supported(ctrl))
134136
dev_warn_once(ctrl->device,
135137
"using unchecked metadata buffer\n");
@@ -139,8 +141,10 @@ static int nvme_map_user_request(struct request *req, u64 ubuffer,
139141
struct iov_iter iter;
140142

141143
/* fixedbufs is only for non-vectored io */
142-
if (WARN_ON_ONCE(flags & NVME_IOCTL_VEC))
143-
return -EINVAL;
144+
if (WARN_ON_ONCE(flags & NVME_IOCTL_VEC)) {
145+
ret = -EINVAL;
146+
goto out;
147+
}
144148
ret = io_uring_cmd_import_fixed(ubuffer, bufflen,
145149
rq_data_dir(req), &iter, ioucmd);
146150
if (ret < 0)

0 commit comments

Comments
 (0)