From patchwork Sat Jul 29 20:37:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 128177 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp1245347vqg; Sat, 29 Jul 2023 16:09:04 -0700 (PDT) X-Google-Smtp-Source: APBJJlF9sr1SaJ0JSkqJRsoxxXm4WxqjRnKsW4uoQODEoQbIR+qfnFwqRbHco21g1Pi+n7nkIYsw X-Received: by 2002:a05:6a21:3806:b0:13d:315f:26b7 with SMTP id yi6-20020a056a21380600b0013d315f26b7mr2108076pzb.1.1690672144397; Sat, 29 Jul 2023 16:09:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690672144; cv=none; d=google.com; s=arc-20160816; b=oQyLlFGSFp6VRqIOsoybhR5kVI+OxKLBVrlP/ia0Ns3RJ0nvzmqZUmZUvZO9PVs926 B7vxCHqzDEAhuspToDTIToH7OO4Y/uWwbD7mQY+XH3E3ClEfLFRBwTKMmjc+U2nGvAOT G3Nozectn/lJJ2Q/TD+6qGcrAhDcoZsTQ/Wxs9+mbdLvxdCwbJzdLTZ3bfaKwGfs9BAG b3ntWavFAEON5OD3dnKFBmLWaSL1A65YLZmR5L3DB2au3IlTeT0oPHmgbfSMITZ5Sph8 34MYhEcBQl67/b2nTVPvXXG9tcM9GCdytbwil7AsaDxl5YsETXxJdXS7PErO7Z9eJ4/e CUhQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=LNXZOYVbCHsualccFqzRqzpRLiqhfT1W4JZoiRNqVK8=; fh=0gqAt1aL4tMWE9LT2ysuiUaU99Ov/zltMhb1IZiOX6M=; b=W5UoH/cbv0P1GWGCtOZKFfcpWZGSCjB6g0JFXsHSktu0+XChCDU6nv5kxFTp8EQg1j 6yxBJikMrKVQ4hHYqbSPzZn6OFF+Z5WfdKj+v2VcvRp1DniyI/KbPt9/mduMfq1IPIa0 f81L/a6YqnX8+fuZ8UkTzUh32OTSsg8v6zJ2gADJOUnkN/S3MBeoVYT9Nvo2r/2Fjyf0 Ho9p8eTuVvnura2W4iU28dOTbr0V+aJ/7iDtCYuajTwy5+NM/18xB6vQ1LAoue3l77bZ D5q+qu4QYgUr57smU7HtXlSQRVTJa6xoUg0KUYf0jf2TQcfowE1BOIZ5PzforQ/GgB0t mqjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UyYSf2rL; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t63-20020a638142000000b00563489de9e3si1378660pgd.505.2023.07.29.16.08.51; Sat, 29 Jul 2023 16:09:04 -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=UyYSf2rL; 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 S229577AbjG2Uhs (ORCPT + 99 others); Sat, 29 Jul 2023 16:37:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229454AbjG2Uhl (ORCPT ); Sat, 29 Jul 2023 16:37:41 -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 3F8F41709; Sat, 29 Jul 2023 13:37:40 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B206660AF3; Sat, 29 Jul 2023 20:37:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 76B03C433C8; Sat, 29 Jul 2023 20:37:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690663059; bh=YPgSpddY9t4io6ikXCAUlDHPpj8ulBukto96IBJDPnc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UyYSf2rL2uLdPSrcPn4/N9GQkTxV2zBIT8nd/j+Pzf7IOWlL0PseartNH8Cn0JhVZ COd+atrvWOy+pR5Xj10r0PicBAH309HUuAWue8TI+VqsKvXlV/1j5hjW/IJwfzhjsJ wV/VG0X1OD3dUfsEC1DHpVRHoKSAsqBmBBZUq2c6b55yGCMYY7xgXL8VF9fvAcRam+ RdZEJzlrf/XHTZGqM8gvZZPBzuogVfCrwuWJPElLFGLb5X+WwtAd2KwiZfAL/lRcp3 f1eCVHWjTgJVP6BQ/P/aJT8bfaoszMfOqWxMO0UQDiVLvKEaeMfWs9vucDczB2xF5O wJb9IiQv4jIZQ== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Brendan Higgins , damon@lists.linux.dev, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, stable@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] mm/damon/core-test: add a test for damos_new_filter() Date: Sat, 29 Jul 2023 20:37:33 +0000 Message-Id: <20230729203733.38949-3-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230729203733.38949-1-sj@kernel.org> References: <20230729203733.38949-1-sj@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772798234337152430 X-GMAIL-MSGID: 1772798234337152430 damos_new_filter() was having a bug that not initializing ->list field of the returning damos_filter struct, which results in access to uninitialized memory. Add a unit test for the function. Cc: stable@vger.kernel.org # 6.3.x- Signed-off-by: SeongJae Park --- mm/damon/core-test.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/mm/damon/core-test.h b/mm/damon/core-test.h index bb07721909e1..4bddbfe243c3 100644 --- a/mm/damon/core-test.h +++ b/mm/damon/core-test.h @@ -341,6 +341,18 @@ static void damon_test_set_attrs(struct kunit *test) KUNIT_EXPECT_EQ(test, damon_set_attrs(c, &invalid_attrs), -EINVAL); } +static void damos_test_new_filter(struct kunit *test) +{ + struct damos_filter *filter; + + filter = damos_new_filter(DAMOS_FILTER_TYPE_ANON, true); + KUNIT_EXPECT_EQ(test, filter->type, DAMOS_FILTER_TYPE_ANON); + KUNIT_EXPECT_EQ(test, filter->matching, true); + KUNIT_EXPECT_PTR_EQ(test, filter->list.prev, &filter->list); + KUNIT_EXPECT_PTR_EQ(test, filter->list.next, &filter->list); + damos_destroy_filter(filter); +} + static struct kunit_case damon_test_cases[] = { KUNIT_CASE(damon_test_target), KUNIT_CASE(damon_test_regions), @@ -353,6 +365,7 @@ static struct kunit_case damon_test_cases[] = { KUNIT_CASE(damon_test_set_regions), KUNIT_CASE(damon_test_update_monitoring_result), KUNIT_CASE(damon_test_set_attrs), + KUNIT_CASE(damos_test_new_filter), {}, };