lkml.org 
[lkml]   [2023]   [Aug]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] drivers: nvdimm: fix dereference after free
From


On 8/17/23 08:45, Dave Jiang wrote:
>
>
> On 8/17/23 04:41, Konstantin Meskhidze wrote:
>> 'nd_pmu->pmu.attr_groups' is dereferenced in function
>> 'nvdimm_pmu_free_hotplug_memory' call after it has been freed. Because in
>> function 'nvdimm_pmu_free_hotplug_memory' memory pointed by the fields of
>> 'nd_pmu->pmu.attr_groups' is deallocated it is necessary to call 'kfree'
>> after 'nvdimm_pmu_free_hotplug_memory'.
>>
>> Co-developed-by: Ivanov Mikhail <ivanov.mikhail1@huawei-partners.com>
>> Signed-off-by: Konstantin Meskhidze <konstantin.meskhidze@huawei.com>
>
> LGTM
>
> Does this need a Fixes tag?

Applied. Modified subject to "nvdimm: Fix dereference after free in
register_nvdimm_pmu()"

Also added Fixes tag:
Fixes: 0fab1ba6ad6b ("drivers/nvdimm: Add perf interface to expose
nvdimm performance stats")


>
>> ---
>>   drivers/nvdimm/nd_perf.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/nvdimm/nd_perf.c b/drivers/nvdimm/nd_perf.c
>> index 14881c4e0..2b6dc80d8 100644
>> --- a/drivers/nvdimm/nd_perf.c
>> +++ b/drivers/nvdimm/nd_perf.c
>> @@ -307,10 +307,10 @@ int register_nvdimm_pmu(struct nvdimm_pmu
>> *nd_pmu, struct platform_device *pdev)
>>       }
>>       rc = perf_pmu_register(&nd_pmu->pmu, nd_pmu->pmu.name, -1);
>>       if (rc) {
>> -        kfree(nd_pmu->pmu.attr_groups);
>>           nvdimm_pmu_free_hotplug_memory(nd_pmu);
>> +        kfree(nd_pmu->pmu.attr_groups);
>>           return rc;
>>       }
>>       pr_info("%s NVDIMM performance monitor support registered\n",
>

\
 
 \ /
  Last update: 2023-08-17 18:09    [W:0.073 / U:0.112 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site