blktests nvme 041,042 leak memory
Maurizio Lombardi
mlombard at redhat.com
Wed May 29 06:45:02 PDT 2024
st 29. 5. 2024 v 14:51 odesílatel Sagi Grimberg <sagi at grimberg.me> napsal:
>
> --
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index f62fd49c1411..8a9d51e1ccd6 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -4702,6 +4702,14 @@ int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct
> device *dev,
> nvme_fault_inject_fini(&ctrl->fault_inject);
> dev_pm_qos_hide_latency_tolerance(ctrl->device);
> cdev_device_del(&ctrl->cdev, ctrl->device);
> + /*
> + * this is nasty hack, but device_add allocated a device private
> + * dev->p, which is freed assymmetricly in device_release, and
> + * in order to cleanup after ourselves, and not rely on the device
> + * .release handler (which also calls the nvme transport free
> handler)
> + * we explicitly free the device private.
> + */
> + kfree(ctrl->device->p);
> out_free_name:
> nvme_put_ctrl(ctrl);
> kfree_const(ctrl->device->kobj.name)
> --
>
> But this is ugly...
>
I like the fact that it's just a one-liner in nvme_init_ctrl, but
yes... it's really a hack that may stop working if device_add()'s
implementation changes.
Maurizio
More information about the Linux-nvme
mailing list