From nobody Mon Apr 6 14:55:00 2026 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 129B0C433FE for ; Sun, 2 Oct 2022 19:31:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229754AbiJBTbm (ORCPT ); Sun, 2 Oct 2022 15:31:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229449AbiJBTbi (ORCPT ); Sun, 2 Oct 2022 15:31:38 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 095953AB13 for ; Sun, 2 Oct 2022 12:31:37 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8A0F560ECC for ; Sun, 2 Oct 2022 19:31:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6ADC4C433D6; Sun, 2 Oct 2022 19:31:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664739096; bh=bQS/eXJeMiPmj71PLej7rSCZfOQeTrzaD8xCsX+qwWs=; h=From:To:Cc:Subject:Date:From; b=mqXGGEijWGYOiDoFBLN96KIHMPXk+iRXIEhFZEthkWkhHbII4hJTk8mU7LmVLy5Hb 27BrqgLA7UBZEmpgEnID8xnk6WO0IGDFKavvDraIxLFdEbbt/bmMCDhtEWDyM8u7aQ yI+/LFUrOlsM1ulAgbtmQxXx5kOqO55fG59CsmEiJ5elUp6M3tiNfsCmq7pqLCMXoZ PbWKrJE01GK1Gt0BUUXA9wxzzh3sAwSL6vF3F1rgr/zEyXKuyp1CuwunE6vDOqW5Zi khuo8Dk5lBvSZ6cMAIlkRdtunin+/MAJCHpz6LYqi5cpCkFwVPDTIoFpa8Spw2bFcR kkDribUKFF/Cg== From: SeongJae Park To: akpm@linux-foundation.org Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, SeongJae Park , Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [PATCH] mm/damon/core: initialize damon_target->list in damon_new_target() Date: Sun, 2 Oct 2022 19:31:30 +0000 Message-Id: <20221002193130.8227-1-sj@kernel.org> X-Mailer: git-send-email 2.25.1 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" 'struct damon_target' creation function, 'damon_new_target()' is not initializing its '->list' field, unlike other DAMON structs creator functions such as 'damon_new_region()'. Normal users of 'damon_new_target()' initializes the field by adding the target to DAMON context's targets list, but some code could access the uninitialized field. This commit avoids the case by initializing the field in 'damon_new_target()'. Reported-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Fixes: f23b8eee1871 ("mm/damon/core: implement region-based sampling") Signed-off-by: SeongJae Park Tested-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/damon/core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/damon/core.c b/mm/damon/core.c index 1d952fa7ba3e..1e6691771a95 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -345,6 +345,7 @@ struct damon_target *damon_new_target(void) t->pid =3D NULL; t->nr_regions =3D 0; INIT_LIST_HEAD(&t->regions_list); + INIT_LIST_HEAD(&t->list); =20 return t; } --=20 2.25.1