Skip to contentSkip to conversation

nvme: fix memory leak for power latency tolerance req

PATCH New Yufen Yu 4 participants 6 messages May 17, 2019 – May 24, 2019 NVMe

lore
Share & tools
lore

Yufen Yu

author
#0 lore raw

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().

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 +1 -0
index 15d114787d6a..e13670dcf590 100644
@@ -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
#1 lore raw

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 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().

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
index 15d114787d6a..e13670dcf590 100644

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

Tested-by David Milburn <dmilburn at redhat.com>
maintainer Applied
#2 lore raw

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

maintainer
#3 lore raw

PATCH 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...

maintainer
#4 lore raw

PATCH 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+.

maintainer
#5 lore raw

PATCH 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+