[linux-next,v2,2/3] drivers/platform/x86/intel/tpmi: revise the comment of intel_vsec_add_aux

Message ID 20230309040107.534716-3-dzm91@hust.edu.cn
State New
Headers
Series [linux-next,v2,1/3] platform/x86/intel/tpmi: Fix double free in tpmi_create_device() |

Commit Message

Dongliang Mu March 9, 2023, 4:01 a.m. UTC
  intel_vsec_add_aux() is resource managed including res and
feature_vsec_dev memory.

Fix this by revising the comment of intel_vsec_add_aux since res variable
will also be freed in the intel_vsec_add_aux.

Signed-off-by: Dongliang Mu <dzm91@hust.edu.cn>
---
 drivers/platform/x86/intel/tpmi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Hans de Goede March 20, 2023, 10:33 a.m. UTC | #1
Hi,

On 3/9/23 05:01, Dongliang Mu wrote:
> intel_vsec_add_aux() is resource managed including res and
> feature_vsec_dev memory.
> 
> Fix this by revising the comment of intel_vsec_add_aux since res variable
> will also be freed in the intel_vsec_add_aux.
> 
> Signed-off-by: Dongliang Mu <dzm91@hust.edu.cn>

Thank you for your patch, I've applied this patch to my review-hans 
branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans

Note it will show up in my review-hans branch once I've pushed my
local branch there, which might take a while.

Once I've run some tests on this branch the patches there will be
added to the platform-drivers-x86/for-next branch and eventually
will be included in the pdx86 pull-request to Linus for the next
merge-window.

Regards,

Hans



> ---
>  drivers/platform/x86/intel/tpmi.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/platform/x86/intel/tpmi.c b/drivers/platform/x86/intel/tpmi.c
> index 882fe5e4763f..036d0e0dba19 100644
> --- a/drivers/platform/x86/intel/tpmi.c
> +++ b/drivers/platform/x86/intel/tpmi.c
> @@ -239,8 +239,8 @@ static int tpmi_create_device(struct intel_tpmi_info *tpmi_info,
>  	/*
>  	 * intel_vsec_add_aux() is resource managed, no explicit
>  	 * delete is required on error or on module unload.
> -	 * feature_vsec_dev memory is also freed as part of device
> -	 * delete.
> +	 * feature_vsec_dev and res memory are also freed as part of
> +	 * device deletion.
>  	 */
>  	return intel_vsec_add_aux(vsec_dev->pcidev, &vsec_dev->auxdev.dev,
>  				  feature_vsec_dev, feature_id_name);
  
Dongliang Mu March 20, 2023, 10:57 a.m. UTC | #2
On 2023/3/20 18:33, Hans de Goede wrote:
> Hi,
>
> On 3/9/23 05:01, Dongliang Mu wrote:
>> intel_vsec_add_aux() is resource managed including res and
>> feature_vsec_dev memory.
>>
>> Fix this by revising the comment of intel_vsec_add_aux since res variable
>> will also be freed in the intel_vsec_add_aux.
>>
>> Signed-off-by: Dongliang Mu <dzm91@hust.edu.cn>
> Thank you for your patch, I've applied this patch to my review-hans
> branch:
> https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans
>
> Note it will show up in my review-hans branch once I've pushed my
> local branch there, which might take a while.
>
> Once I've run some tests on this branch the patches there will be
> added to the platform-drivers-x86/for-next branch and eventually
> will be included in the pdx86 pull-request to Linus for the next
> merge-window.
>
> Regards,
>
> Hans

Thanks, Hans.

Shall I send the patch related to memory leak to the mainline? The 
mainline is also prone to this issue?

>
>
>
>> ---
>>   drivers/platform/x86/intel/tpmi.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/platform/x86/intel/tpmi.c b/drivers/platform/x86/intel/tpmi.c
>> index 882fe5e4763f..036d0e0dba19 100644
>> --- a/drivers/platform/x86/intel/tpmi.c
>> +++ b/drivers/platform/x86/intel/tpmi.c
>> @@ -239,8 +239,8 @@ static int tpmi_create_device(struct intel_tpmi_info *tpmi_info,
>>   	/*
>>   	 * intel_vsec_add_aux() is resource managed, no explicit
>>   	 * delete is required on error or on module unload.
>> -	 * feature_vsec_dev memory is also freed as part of device
>> -	 * delete.
>> +	 * feature_vsec_dev and res memory are also freed as part of
>> +	 * device deletion.
>>   	 */
>>   	return intel_vsec_add_aux(vsec_dev->pcidev, &vsec_dev->auxdev.dev,
>>   				  feature_vsec_dev, feature_id_name);
  
Hans de Goede March 20, 2023, 1:40 p.m. UTC | #3
Hi,

On 3/20/23 11:57, Dongliang Mu wrote:
> 
> On 2023/3/20 18:33, Hans de Goede wrote:
>> Hi,
>>
>> On 3/9/23 05:01, Dongliang Mu wrote:
>>> intel_vsec_add_aux() is resource managed including res and
>>> feature_vsec_dev memory.
>>>
>>> Fix this by revising the comment of intel_vsec_add_aux since res variable
>>> will also be freed in the intel_vsec_add_aux.
>>>
>>> Signed-off-by: Dongliang Mu <dzm91@hust.edu.cn>
>> Thank you for your patch, I've applied this patch to my review-hans
>> branch:
>> https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans
>>
>> Note it will show up in my review-hans branch once I've pushed my
>> local branch there, which might take a while.
>>
>> Once I've run some tests on this branch the patches there will be
>> added to the platform-drivers-x86/for-next branch and eventually
>> will be included in the pdx86 pull-request to Linus for the next
>> merge-window.
>>
>> Regards,
>>
>> Hans
> 
> Thanks, Hans.
> 
> Shall I send the patch related to memory leak to the mainline? The mainline is also prone to this issue?

There is no need for this, I have just moved these from my review-hans branch to the fixes
branch: https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=fixes

So these will be included in my next fixes pull-req for mainline.

Regards,

Hans




>>> ---
>>>   drivers/platform/x86/intel/tpmi.c | 4 ++--
>>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/platform/x86/intel/tpmi.c b/drivers/platform/x86/intel/tpmi.c
>>> index 882fe5e4763f..036d0e0dba19 100644
>>> --- a/drivers/platform/x86/intel/tpmi.c
>>> +++ b/drivers/platform/x86/intel/tpmi.c
>>> @@ -239,8 +239,8 @@ static int tpmi_create_device(struct intel_tpmi_info *tpmi_info,
>>>       /*
>>>        * intel_vsec_add_aux() is resource managed, no explicit
>>>        * delete is required on error or on module unload.
>>> -     * feature_vsec_dev memory is also freed as part of device
>>> -     * delete.
>>> +     * feature_vsec_dev and res memory are also freed as part of
>>> +     * device deletion.
>>>        */
>>>       return intel_vsec_add_aux(vsec_dev->pcidev, &vsec_dev->auxdev.dev,
>>>                     feature_vsec_dev, feature_id_name);
>
  

Patch

diff --git a/drivers/platform/x86/intel/tpmi.c b/drivers/platform/x86/intel/tpmi.c
index 882fe5e4763f..036d0e0dba19 100644
--- a/drivers/platform/x86/intel/tpmi.c
+++ b/drivers/platform/x86/intel/tpmi.c
@@ -239,8 +239,8 @@  static int tpmi_create_device(struct intel_tpmi_info *tpmi_info,
 	/*
 	 * intel_vsec_add_aux() is resource managed, no explicit
 	 * delete is required on error or on module unload.
-	 * feature_vsec_dev memory is also freed as part of device
-	 * delete.
+	 * feature_vsec_dev and res memory are also freed as part of
+	 * device deletion.
 	 */
 	return intel_vsec_add_aux(vsec_dev->pcidev, &vsec_dev->auxdev.dev,
 				  feature_vsec_dev, feature_id_name);