Re: [PATCH] PM / devfreq: fix mem leak and missing check of return value in devfreq_add_device()

From: Frank Lee
Date: Sat Jan 19 2019 - 11:08:56 EST


> Also, you better to add following codes to free the memory of
> 'devfreq->trans_table' and 'devfreq->time_in_state' because this patch
> handles the memory leak of 'trans_table' and 'time_in_state'
> variables.
Hi Chanwoo:

Isn't that the mem requested by the devm_ API automatically freed when
the device is detached?
So we don't need to pay attention to free these mem.

Thanksï
Yangtao
>
> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> index 0ae3de7..945f5f1 100644
> --- a/drivers/devfreq/devfreq.c
> +++ b/drivers/devfreq/devfreq.c
> @@ -593,6 +593,9 @@ static void devfreq_dev_release(struct device *dev)
> devfreq->profile->exit(devfreq->dev.parent);
>
> mutex_destroy(&devfreq->lock);
> + kfree(devfreq->trans_table);
> + kfree(devfreq->time_in_state);
> kfree(devfreq);
> }
>
> --
> Best Regards,
> Chanwoo Choi
> Samsung Electronics