[PATCH v4 06/11] misc: fastrpc: Fix memory leak in audio daemon attach operation

Ekansh Gupta posted 11 patches 1 year, 6 months ago
[PATCH v4 06/11] misc: fastrpc: Fix memory leak in audio daemon attach operation
Posted by Ekansh Gupta 1 year, 6 months ago
Audio PD daemon send the name as part of the init IOCTL call. This
mane needs to be copied to kernel for which memory is allocated.
This memory is never freed which might result in memory leak. Add
changes to free the memory when it is not needed.

Fixes: 0871561055e6 ("misc: fastrpc: Add support for audiopd")
Cc: stable <stable@kernel.org>
Signed-off-by: Ekansh Gupta <quic_ekangupt@quicinc.com>
---
 drivers/misc/fastrpc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 13e368279765..7ee8bb3a9a6f 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -1380,6 +1380,7 @@ static int fastrpc_init_create_static_process(struct fastrpc_user *fl,
 		goto err_invoke;
 
 	kfree(args);
+	kfree(name);
 
 	return 0;
 err_invoke:
-- 
2.43.0
Re: [PATCH v4 06/11] misc: fastrpc: Fix memory leak in audio daemon attach operation
Posted by Dmitry Baryshkov 1 year, 6 months ago
On Thu, Jun 06, 2024 at 10:29:26PM +0530, Ekansh Gupta wrote:
> Audio PD daemon send the name as part of the init IOCTL call. This
> mane needs to be copied to kernel for which memory is allocated.
> This memory is never freed which might result in memory leak. Add
> changes to free the memory when it is not needed.
> 
> Fixes: 0871561055e6 ("misc: fastrpc: Add support for audiopd")
> Cc: stable <stable@kernel.org>
> Signed-off-by: Ekansh Gupta <quic_ekangupt@quicinc.com>

Fixes go before the non-fixes patches.

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

> ---
>  drivers/misc/fastrpc.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
> index 13e368279765..7ee8bb3a9a6f 100644
> --- a/drivers/misc/fastrpc.c
> +++ b/drivers/misc/fastrpc.c
> @@ -1380,6 +1380,7 @@ static int fastrpc_init_create_static_process(struct fastrpc_user *fl,
>  		goto err_invoke;
>  

A comment that the remote_heap persists would be helpful.

>  	kfree(args);
> +	kfree(name);
>  
>  	return 0;
>  err_invoke:
> -- 
> 2.43.0
> 

-- 
With best wishes
Dmitry
Re: [PATCH v4 06/11] misc: fastrpc: Fix memory leak in audio daemon attach operation
Posted by Ekansh Gupta 1 year, 6 months ago

On 6/7/2024 4:58 PM, Dmitry Baryshkov wrote:
> On Thu, Jun 06, 2024 at 10:29:26PM +0530, Ekansh Gupta wrote:
>> Audio PD daemon send the name as part of the init IOCTL call. This
>> mane needs to be copied to kernel for which memory is allocated.
>> This memory is never freed which might result in memory leak. Add
>> changes to free the memory when it is not needed.
>>
>> Fixes: 0871561055e6 ("misc: fastrpc: Add support for audiopd")
>> Cc: stable <stable@kernel.org>
>> Signed-off-by: Ekansh Gupta <quic_ekangupt@quicinc.com>
> Fixes go before the non-fixes patches.
>
> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
>
>> ---
>>  drivers/misc/fastrpc.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
>> index 13e368279765..7ee8bb3a9a6f 100644
>> --- a/drivers/misc/fastrpc.c
>> +++ b/drivers/misc/fastrpc.c
>> @@ -1380,6 +1380,7 @@ static int fastrpc_init_create_static_process(struct fastrpc_user *fl,
>>  		goto err_invoke;
>>  
> A comment that the remote_heap persists would be helpful.
I'll add this information in remote heap redesign patch. Thanks.

--ekansh
>
>>  	kfree(args);
>> +	kfree(name);
>>  
>>  	return 0;
>>  err_invoke:
>> -- 
>> 2.43.0
>>