[mm-unstable,1/2] mm/damon/sysfs-schemes: Fix leaking a filter for wrong cgroup path
Message ID | 20221219171807.55708-2-sj@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp2524703wrn; Mon, 19 Dec 2022 09:41:57 -0800 (PST) X-Google-Smtp-Source: AA0mqf6VardviBy5Txfz0yuEhC5jOWA1ZfualWTJPXaiDmeLVTfOKWMJ7idzVoX8lYcK7kvBHBvE X-Received: by 2002:a17:906:d8a5:b0:7c1:6f86:eeb with SMTP id qc5-20020a170906d8a500b007c16f860eebmr29063987ejb.7.1671471717695; Mon, 19 Dec 2022 09:41:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671471717; cv=none; d=google.com; s=arc-20160816; b=OOR3+ibjiqoK6XsPQw44OnCty73nFHnMramk9mFQPyOGBoYKShC8szTAEZ3MMwB9OC ga7RDddu3pkOld3ySvrO7aZA6VoGmBPKAdqZUUmSPmoMQCfTQz0DFYIt5GLqo2D0ubs2 zDkVmiy4umtoLnWNJoL0ah6YnBCuW/mlSE/0BL2ND3OVGr0n7Tj6mnX/5E2C30UMeqE+ L4br1q2e8zoXlbIAjZnEZb5gNhVJ2x/lhZCXO9Xf+4dJduWe85VhuwjNpZa3Tw548y4S YloNEmsaEOPL/ybX/IXPjtLS31WM4LnbLV5kNiIQovYVI03c3gZqSo8fPNnX+QPDzAqp HqDw== 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 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.41.34; Mon, 19 Dec 2022 09:41:57 -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 <rfc822;abdi.embedded@gmail.com> + 99 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 <rfc822;linux-kernel@vger.kernel.org>); 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 <linux-kernel@vger.kernel.org>; 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 <linux-kernel@vger.kernel.org>; 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 <sj@kernel.org> To: Andrew Morton <akpm@linux-foundation.org> Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, SeongJae Park <sj@kernel.org> 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752665127624084687?= X-GMAIL-MSGID: =?utf-8?q?1752665127624084687?= |
Series |
two fixups for DAMON sysfs' scheme filters support
|
|
Commit Message
SeongJae Park
Dec. 19, 2022, 5:18 p.m. UTC
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 <sj@kernel.org>
---
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); }