set the pointer to NULL after free the memory in free_percpu, so there is no need to set the pointer to NULL in the driver after calling free_percpu again.
Signed-off-by: Tian Tao tiantao6@hisilicon.com --- mm/percpu.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/mm/percpu.c b/mm/percpu.c index f53b89b..af944cc 100644 --- a/mm/percpu.c +++ b/mm/percpu.c @@ -2121,6 +2121,8 @@ void free_percpu(void __percpu *ptr)
if (need_balance) pcpu_schedule_balance_work(); + + ptr = NULL; } EXPORT_SYMBOL_GPL(free_percpu);
-----Original Message----- From: tiantao (H) Sent: Wednesday, January 27, 2021 12:41 AM To: Jonathan Cameron jonathan.cameron@huawei.com; Song Bao Hua (Barry Song) song.bao.hua@hisilicon.com Cc: linuxarm@openeuler.org; tiantao (H) tiantao6@hisilicon.com Subject: [PATCH] percpu: set the pointer to NULL after free the memory in free_percpu
set the pointer to NULL after free the memory in free_percpu, so there is no need to set the pointer to NULL in the driver after calling free_percpu again.
Signed-off-by: Tian Tao tiantao6@hisilicon.com
mm/percpu.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/mm/percpu.c b/mm/percpu.c index f53b89b..af944cc 100644 --- a/mm/percpu.c +++ b/mm/percpu.c @@ -2121,6 +2121,8 @@ void free_percpu(void __percpu *ptr)
if (need_balance) pcpu_schedule_balance_work();
- ptr = NULL;
This doesn't work as we are changing the temp ptr only Unless users give a **ptr, we can do *ptr=null.
} EXPORT_SYMBOL_GPL(free_percpu);
-- 2.7.4
Thanks Barry