From nobody Fri Dec 19 09:51:19 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6FE51EE14BC for ; Wed, 6 Sep 2023 17:39:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240806AbjIFRjN (ORCPT ); Wed, 6 Sep 2023 13:39:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230258AbjIFRjM (ORCPT ); Wed, 6 Sep 2023 13:39:12 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 940E6199B for ; Wed, 6 Sep 2023 10:39:08 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 445C3C433C7; Wed, 6 Sep 2023 17:39:07 +0000 (UTC) From: Catalin Marinas To: tj@kernel.org Cc: linux-kernel@vger.kernel.org, dhavale@google.com Subject: [PATCH] workqueue: Remove duplicate worqueue attributes allocation Date: Wed, 6 Sep 2023 18:39:04 +0100 Message-Id: <20230906173904.475722-1-catalin.marinas@arm.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Commit 84193c07105c ("workqueue: Generalize unbound CPU pods") inadvertently introduced another call to alloc_workqueue_attrs() overriding the pointer returned by a previous alloc_workqueue_attrs() a few lines up in workqueue_init_early(). This leads to a kmemleak report: unreferenced object 0xffff000040015000 (size 96): comm "swapper/0", pid 0, jiffies 4294892296 (age 163.956s) hex dump (first 32 bytes): 00 00 00 00 00 00 00 00 03 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace: [<000000004cec0d50>] __kmem_cache_alloc_node+0x1c4/0x288 [<0000000083361c2a>] kmalloc_trace+0x20/0x2c [<000000005ca61f11>] workqueue_init_early+0xe4/0x538 [<000000004e6ea358>] start_kernel+0x23c/0x5ec [<00000000aea9761e>] __primary_switched+0xbc/0xc4 Remove the first allocation. Fixes: 84193c07105c ("workqueue: Generalize unbound CPU pods") Signed-off-by: Catalin Marinas Cc: Tejun Heo Reviewed-by: Sandeep Dhavale Tested-by: Matthieu Baerts --- I've seen this mentioned by Sandeep as well but I couldn't find a patch, so here it is. https://lore.kernel.org/r/CAB=3DBE-S=3DcxewXu7nqJY1DC5w9Bapar_C0cTjpZOQ-Qd5= GGwYyw@mail.gmail.com/ kernel/workqueue.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index c85825e17df8..43ab8399b72b 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -6524,9 +6524,6 @@ void __init workqueue_init_early(void) =20 pwq_cache =3D KMEM_CACHE(pool_workqueue, SLAB_PANIC); =20 - wq_update_pod_attrs_buf =3D alloc_workqueue_attrs(); - BUG_ON(!wq_update_pod_attrs_buf); - /* initialize WQ_AFFN_SYSTEM pods */ pt->pod_cpus =3D kcalloc(1, sizeof(pt->pod_cpus[0]), GFP_KERNEL); pt->pod_node =3D kcalloc(1, sizeof(pt->pod_node[0]), GFP_KERNEL);