Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp2864790rwj; Mon, 19 Dec 2022 09:43:06 -0800 (PST) X-Google-Smtp-Source: AMrXdXs1RzD2NMOa0vPbqM/wBWOm0X6R4SiGcVRdUf3Q6SFCRawDj04+9W5zEwgyVB9uQ7rit9AJ X-Received: by 2002:a17:906:a20d:b0:7fc:4242:f9e9 with SMTP id r13-20020a170906a20d00b007fc4242f9e9mr8290826ejy.70.1671471785813; Mon, 19 Dec 2022 09:43:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671471785; cv=none; d=google.com; s=arc-20160816; b=xWwmYvxKWIeB+tkuRhweub2P6i7EF+23HNdS4bl+AOz24sNOfXJsd+QmxAYXq1vKgM CxNhgxXaf40QmfVKdF+4TZZWGFRi1oBmiZmm6+uhnALUodtXNwag0IFodjLdcuGV6dJu PCRtCAmAvXG4xDL8rD76mDddkPcPJyt4ZMOYWAbwL4iM75W+yL/feXwY6WERW+xJ7f8E pn5to2FEYlwD76Kt+T2vzGY9g6I5WG+i9HzLgwRzdO+efNt+EHBmcWKC4xxqCmPuJhEn u3KChg6KN3Bkjo5sSKa0e2N5sCvGqTB9K2gG1mBWHsURY/wVqVD9SFTKoBEs80p1A4rA TVVw== 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=028VkuVj4jjygfiyG/8RNBMLnORgopVRbdgD0WylOOo=; b=biRnOyippvttmbtGGDDehzDXgq9AG3Kzaj6YlcPzY9Q4zONsGpTLaYOPoGMMUL7Nz7 l69llvcKu9J5VteCAHt014AZjzzF+ph5Dn9SB+2LfGoRq8+cjLfJG49Wkd9Qg/dZahc7 MjEFiAJqCK8jcrowZ6P1PLPC0rCZh560dwyuGnMK80b3FL+ZK974LhfdoZLUVU1kyHy2 4mIaF7nG0D9jCPb51wXbTUXIEKrc4nE4JtD7ACpp43Dh8vmuq613N2CY9XTBgbXByonQ 0gM3PphuQ8r4JnBZB765p3fU6pTIuJSljokEXC1GWS+kV2okhxGp0nDxbB5SSe1ZwklI Ce2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=L7iuXB5Z; 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 hq41-20020a1709073f2900b007ae74740fa4si10786605ejc.275.2022.12.19.09.42.46; Mon, 19 Dec 2022 09:43:05 -0800 (PST) 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=L7iuXB5Z; 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 S232369AbiLSRSW (ORCPT + 70 others); Mon, 19 Dec 2022 12:18:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232267AbiLSRSQ (ORCPT ); Mon, 19 Dec 2022 12:18:16 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB43913E15 for ; Mon, 19 Dec 2022 09:18:14 -0800 (PST) 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 579416108C for ; Mon, 19 Dec 2022 17:18:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 588B5C433F0; Mon, 19 Dec 2022 17:18:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1671470293; bh=Az1DXboUgRl+YAMk48Zah7TQBLUIJ4ua1EMPirQ5/3o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L7iuXB5ZEm6O0EUjdxu5DQDi6cpCEpzeu3Zsa9iJyPi1H/rZSq/6M5VA7cUOv1WH8 NVdoiSN3kxcVWbmlgVaZARrAW6n7M3KikLiJxzQKSc8wJkL+dPjnJs0eHGv1VmJFep 4PejNW+g758e7hTjmRmXx/epWzJrVzgg9d3jH1rTSyByV7g1kCvlqvOJ3mtLtC+xwz 107NmX9Um9h8GKmqextgzKBM75180RfQ0OKBM7t17wNxns3jG9UT+l8hhtX7ss46GO L8UX0b7e/kkSZJHB/zhPcbEiNjGNKHGkL+ERT9H9Rww1MgZRTiQVat2VYr0EDmOc7g wRi4h5+o1tB7Q== From: SeongJae Park To: Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH mm-unstable 1/2] mm/damon/sysfs-schemes: Fix leaking a filter for wrong cgroup path Date: Mon, 19 Dec 2022 17:18:06 +0000 Message-Id: <20221219171807.55708-2-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221219171807.55708-1-sj@kernel.org> References: <20221219171807.55708-1-sj@kernel.org> 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 Commit f36f860207efa ("mm/damon/sysfs-schemes: implement scheme filters") on mm-unstable introduced 'damon_syfs_set_scheme_filters()', which does not free newly allocated filter when it fails setting memcg id for the filter. As a result, the memory for the filter leaks. Fix it by freeing the filter before returning the error. Coverity CID: 1530032 Fixes: f36f860207ef ("mm/damon/sysfs-schemes: implement scheme filters") on mm-unstable Signed-off-by: SeongJae Park --- mm/damon/sysfs-schemes.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 0501862534f2..5d3ac3107927 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -1464,8 +1464,10 @@ static int damon_sysfs_set_scheme_filters(struct damos *scheme, err = damon_sysfs_memcg_path_to_id( sysfs_filter->memcg_path, &filter->memcg_id); - if (err) + if (err) { + damos_destroy_filter(filter); return err; + } } damos_add_filter(scheme, filter); } -- 2.25.1