Messages in this thread | | | From | "Huang, Ying" <> | Subject | Re: [PATCH -V3 4/4] dax, kmem: calculate abstract distance with general interface | Date | Tue, 19 Sep 2023 13:56:33 +0800 |
| |
Alistair Popple <apopple@nvidia.com> writes:
> Huang Ying <ying.huang@intel.com> writes: > >> diff --git a/mm/memory-tiers.c b/mm/memory-tiers.c >> index fa1a8b418f9a..ca68ef17554b 100644 >> --- a/mm/memory-tiers.c >> +++ b/mm/memory-tiers.c >> @@ -586,7 +586,7 @@ EXPORT_SYMBOL_GPL(init_node_memory_type); >> void clear_node_memory_type(int node, struct memory_dev_type *memtype) >> { >> mutex_lock(&memory_tier_lock); >> - if (node_memory_types[node].memtype == memtype) >> + if (node_memory_types[node].memtype == memtype || !memtype) >> node_memory_types[node].map_count--; >> >> /* >> * If we umapped all the attached devices to this node, > > This implies it's possible memtype == NULL. Yet we have this: > > * clear the node memory type. > */ > if (!node_memory_types[node].map_count) { > node_memory_types[node].memtype = NULL; > put_memory_type(memtype); > } > > It's not safe to call put_memory_type(NULL), so what condition guarantees > map_count > 1 when called with memtype == NULL? Thanks.
Nothing guarantees that. Thanks for pointing this out. I will revise the code to put_memory_type(node_memory_types[node].memtype) firstly.
-- Best Regards, Huang, Ying
| |