From: San Mehat Date: Thu, 6 May 2010 22:40:07 +0000 (-0700) Subject: staging: android: lowmemorykiller: Fix task_struct leak X-Git-Tag: firefly_0821_release~7613^2~734 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=d3ea858955dffd13432737258861f08ec4ef4889;p=firefly-linux-kernel-4.4.55.git staging: android: lowmemorykiller: Fix task_struct leak As it turns out, the CONFIG_PROFILING interfaces leak a task struct if the notifier chain returns NOTIFY_OK.. doh. This patch reworks lowmemkiller to use the new generic task free notifier chain. Signed-off-by: San Mehat --- diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c index 4523093767d4..1204ee0bdf72 100644 --- a/drivers/staging/android/lowmemorykiller.c +++ b/drivers/staging/android/lowmemorykiller.c @@ -34,7 +34,6 @@ #include #include #include -#include #include static uint32_t lowmem_debug_level = 2; @@ -74,7 +73,7 @@ task_notify_func(struct notifier_block *self, unsigned long val, void *data) struct task_struct *task = data; if (task == lowmem_deathpending) { lowmem_deathpending = NULL; - task_handoff_unregister(&task_nb); + task_free_unregister(&task_nb); } return NOTIFY_OK; } @@ -99,8 +98,6 @@ static int lowmem_shrink(int nr_to_scan, gfp_t gfp_mask) * that we have nothing further to offer on * this pass. * - * Note: Currently you need CONFIG_PROFILING - * for this to work correctly. */ if (lowmem_deathpending) return 0; @@ -176,15 +173,8 @@ static int lowmem_shrink(int nr_to_scan, gfp_t gfp_mask) lowmem_print(1, "send sigkill to %d (%s), adj %d, size %d\n", selected->pid, selected->comm, selected_oom_adj, selected_tasksize); - /* - * If CONFIG_PROFILING is off, then task_handoff_register() - * is a nop. In that case we don't want to stall the killer - * by setting lowmem_deathpending. - */ -#ifdef CONFIG_PROFILING lowmem_deathpending = selected; - task_handoff_register(&task_nb); -#endif + task_free_register(&task_nb); force_sig(SIGKILL, selected); rem -= selected_tasksize; }