Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

nvme: fix memory leak freeing command effects

xa_destroy() frees only internal data. The caller is responsible for
freeing the exteranl objects referenced by an xarray.

Fixes: 1cf7a12e09aa4 ("nvme: use an xarray to lookup the Commands Supported and Effects log")
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>

authored by

Keith Busch and committed by
Christoph Hellwig
8168d23f f6224b86

+14 -2
+14 -2
drivers/nvme/host/core.c
··· 4373 4373 } 4374 4374 EXPORT_SYMBOL_GPL(nvme_uninit_ctrl); 4375 4375 4376 + static void nvme_free_cels(struct nvme_ctrl *ctrl) 4377 + { 4378 + struct nvme_effects_log *cel; 4379 + unsigned long i; 4380 + 4381 + xa_for_each (&ctrl->cels, i, cel) { 4382 + xa_erase(&ctrl->cels, i); 4383 + kfree(cel); 4384 + } 4385 + 4386 + xa_destroy(&ctrl->cels); 4387 + } 4388 + 4376 4389 static void nvme_free_ctrl(struct device *dev) 4377 4390 { 4378 4391 struct nvme_ctrl *ctrl = ··· 4395 4382 if (!subsys || ctrl->instance != subsys->instance) 4396 4383 ida_simple_remove(&nvme_instance_ida, ctrl->instance); 4397 4384 4398 - xa_destroy(&ctrl->cels); 4399 - 4385 + nvme_free_cels(ctrl); 4400 4386 nvme_mpath_uninit(ctrl); 4401 4387 __free_page(ctrl->discard_page); 4402 4388