nvme: fix memory leak for power latency tolerance req
PATCH v2 1/1 nvme: fix memory leak for power latency tolerance req
nvme_init_ctrl() initialize latency tolerance controls and kzalloc structdev_pm_qos_request 'req' in nvme_init_ctrl(). The only way to free the 'req' is nvme_init_identify(), when apst is disable and prev_apst is enable.
But, prev_apst is disable when device probe, and we will miss to free it when the device does't support APST.
To fix the problem, we need to hide latency tolerance and free 'req' in nvme_uninit_ctrl().
--- drivers/nvme/host/core.c | 1 + 1 file changed, 1 insertion(+)
drivers/nvme/host/core.c +1 -0
@@ -3687,6 +3687,7 @@ EXPORT_SYMBOL_GPL(nvme_start_ctrl);void nvme_uninit_ctrl (struct nvme_ctrl *ctrl) { +dev_pm_qos_hide_latency_tolerance (ctrl->device);cdev_device_del (&ctrl->cdev, ctrl->device); }EXPORT_SYMBOL_GPL (nvme_uninit_ctrl);
Signature · 1 line
2.16.2.dirty
PATCH v2 1/1 nvme: fix memory leak for power latency tolerance req
Hi,
Quoted 24 lines · Yufen Yu
nvme_init_ctrl()initialize latency tolerance controls and kzallocstructdev_pm_qos_request'req' innvme_init_ctrl(). The only way to free the 'req' isnvme_init_identify(), when apst is disable andprev_apstis enable.But,
prev_apstis disable when device probe, and we will miss to free it when the device does't support APST.To fix the problem, we need to hide latency tolerance and free 'req' in
nvme_uninit_ctrl().Fixes c5552fde102fc("nvme: Enable autonomous power state transitions")Suggested-by Keith Busch <keith.busch at intel.com>Signed-off-by Yufen Yu <yuyufen at huawei.com>--- drivers/nvme/host/core.c | 1 + 1 file changed, 1 insertion(+)drivers/nvme/host/core.c +0
-0
drivers/nvme/host/core.c EXPORT_SYMBOL_GPL(nvme_start_ctrl); · line 3693
Quoted 7 lines
drivers/nvme/host/core.c +1
-0@@ -3687,6 +3687,7 @@ EXPORT_SYMBOL_GPL(nvme_start_ctrl);void nvme_uninit_ctrl (struct nvme_ctrl *ctrl) { +dev_pm_qos_hide_latency_tolerance (ctrl->device);cdev_device_del (&ctrl->cdev, ctrl->device); }EXPORT_SYMBOL_GPL (nvme_uninit_ctrl);
This one works too. Thanks
PATCH v2 1/1 nvme: fix memory leak for power latency tolerance req
Quoted 11 lines · David Milburn
drivers/nvme/host/core.c EXPORT_SYMBOL_GPL(nvme_start_ctrl); · line 3693
Quoted 7 lines · Yufen Yu
void nvme_uninit_ctrl(struct nvme_ctrl *ctrl) {drivers/nvme/host/core.c +1
-0+dev_pm_qos_hide_latency_tolerance (ctrl->device);cdev_device_del (&ctrl->cdev, ctrl->device); }EXPORT_SYMBOL_GPL (nvme_uninit_ctrl);This one works too. Thanks
Quoted 1 line
Tested-by David Milburn <dmilburn at redhat.com>
Thanks, applied for 5.2
Sagi Grimberg
maintainerPATCH v2 1/1 nvme: fix memory leak for power latency tolerance req
Quoted 2 lines
Thanks, applied for 5.2
This should probably be sent to stable as well...
Keith Busch
maintainerPATCH v2 1/1 nvme: fix memory leak for power latency tolerance req
Quoted 4 lines · Sagi Grimberg
Quoted 2 lines
Thanks, applied for 5.2
This should probably be sent to stable as well...
Want to place bets on if stable-bot auto-selects it? :)
But yes, should apply to 4.14+.
Sagi Grimberg
maintainerPATCH v2 1/1 nvme: fix memory leak for power latency tolerance req
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Thanks, applied for 5.2
This should probably be sent to stable as well...
Want to place bets on if stable-bot auto-selects it? :)
But yes, should apply to 4.14+.
Yea, just need to make sure that whoever picks this up tags it for stable # 4.14+