Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2019165rwb; Sun, 2 Oct 2022 13:02:07 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5hvM1ZqGdK/uFGflMjFuWW7arqIxtV7SdSyBPdwiktXg0Kj1iJLMJb/U/zbXb8fNErOP07 X-Received: by 2002:a62:ee17:0:b0:55b:b0d:bc9f with SMTP id e23-20020a62ee17000000b0055b0b0dbc9fmr17029177pfi.39.1664740927203; Sun, 02 Oct 2022 13:02:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664740927; cv=none; d=google.com; s=arc-20160816; b=f/5l20oSZGLxuu4uHIH5AFVtRpg2qSBSaYYa+CmAZuF2493NLYtwcqhG0zCuBfY70m psfq8Qq7XKObZD0Rlf2ryZ0U1qAZRccU1sg6SA4Sv8SngsPIAdpIrT62QLIaNFtRDMvJ WMXAz7zY6aMu1Dq0Fddr29tatKbyXnnkyatLhMH7lOd2wAs/ExbrNJx/7Csa1jmgxhW5 i3Nz3ru0Z/5jXbAvCwRIn5hEezygf+b7rIp/g8HUJRxvnV3tSHMzfy78OPzeMqDuCZUY D4Ru8WalOfEIkLJxu/p+z2rEOcpYReDXW1ytofw3bmQnlUmp3ywEZAhLpDazQLV7WecY wtyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=sugAw9mds9T0qQlUACQlhQreOzIIp7rClyZyJ/e9Mq0=; b=IfwBDeG7NB4EcuBAltdbAYFLoBN8RjNsL77kr9i8mw2RS+gqy8yNXFsZ3WatS70JX/ P52iOnrYYycaMJXJ5VZvoY1vO5Y68bZTq2BmNUD58paBzDdpTwfxcv4O7mkGGgudHidd Y5ZmALEGxSWX2Uz8aFiWrcangweXUx8V5dJVDqXOeFzNxAUg3KqKVu1SlgTZxjpHp3YC p5Yv0JckqFabuj5gwrC8CCbA8Nzva9ODo9GUrBLXjaob3v/g/oyt6pQCZkv0WmbCADur PzcA17FqmnI7R03zDqSMjEGWqChw7SC0XWoZ8JJTMzNFRHABe4uSYRwZtbVHmpnA4zLj C0MA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mqXGGEij; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t64-20020a632d43000000b00434dd6f6e21si8113801pgt.125.2022.10.02.13.01.55; Sun, 02 Oct 2022 13:02:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mqXGGEij; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229919AbiJBTbl (ORCPT + 99 others); Sun, 2 Oct 2022 15:31:41 -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: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org '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 --- 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 = NULL; t->nr_regions = 0; INIT_LIST_HEAD(&t->regions_list); + INIT_LIST_HEAD(&t->list); return t; } -- 2.25.1