From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5DE2035CB7F for ; Thu, 7 May 2026 20:17:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778185059; cv=none; b=rThb2OqVsAM4P0zyBSXXlQjsRuH+M9aEHPzMbJv7/pVTGGBHsELw4te7RGgB6tCDja1iDjEd0M6FrBpD7kX8oR30NuwR7gR0lyXUxAdLuOmFWOFWQMYY/oR4CUNfb4TQNNfwJ65nx4IPnH2wecQbRWwf94OG/kq38TiVNLHVOms= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778185059; c=relaxed/simple; bh=uGIsL3RxJYXZNXX7sBAJLI2zwIQ6CsJGJva/1K4hbFI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Q9zeS0073czyZwD6NoOtdPquMo2U6/vHp9eVZdU+Fzk9OFEqsiN+3PiaPGwmHrpzeyshaon+KcWcuSbJbXzTjnu8qnMjRV2yBpMUWGP1MuKP36EUUrKIIMmEQ2mL4q7XzHa3bb+gUK3xYOFMfY+7BSxokH99lHcNhRx9dRRbhlk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ZyQPReMd; arc=none smtp.client-ip=198.175.65.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ZyQPReMd" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1778185057; x=1809721057; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=uGIsL3RxJYXZNXX7sBAJLI2zwIQ6CsJGJva/1K4hbFI=; b=ZyQPReMdC3aOqoOthJkVivFob0S43ytFR6URvA7LbriDBvsx4bY5wFfo o6n5xP20ROtmW4gQmzaAe2cMF5rzkro6K3nYxkthMU4ciboqYrfH8pGYE eJdpjWzJbqXaupXvXw4m4jx6mxNu2xkqZa31vfhO/pRXJxLRzkvfZdqIS GFE9M/M22QWqe7WlmMwHdq2yhCwBzrxXGsR9YjdQwmGmD7Y8ptWAncNml k1E9MCZeJYR3HEIVCMyXowWG4a3xUeYpQU5OGAEdll6CAkq5E4MzaWcl8 +oaZW6lGMVqM65sAio8avPgsKdHdC78PLt5WiM69AE0ueLw0JxLTu8VV5 g==; X-CSE-ConnectionGUID: HPNplMH6SoiS3AQSX8laMw== X-CSE-MsgGUID: ueS+5XsxTXmOfpSA/z2a8Q== X-IronPort-AV: E=McAfee;i="6800,10657,11779"; a="90250061" X-IronPort-AV: E=Sophos;i="6.23,222,1770624000"; d="scan'208";a="90250061" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2026 13:17:37 -0700 X-CSE-ConnectionGUID: EX2orJXjRI+YzkZMk6e9ng== X-CSE-MsgGUID: uyswiTvoSp27bVLbbSV9qw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,222,1770624000"; d="scan'208";a="233506693" Received: from vverma7-desk1.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.220.9]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2026 13:17:36 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu Cc: Borislav Petkov , x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH] fs/resctrl: Free mon_data structures on rdt_get_tree() failure Date: Thu, 7 May 2026 13:17:30 -0700 Message-ID: <20260507201730.16509-1-tony.luck@intel.com> X-Mailer: git-send-email 2.54.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit If mkdir_mondata_all() succeeds but a subsequent call in rdt_get_tree() fails, the mon_data structures allocated by mon_get_kn_priv() are leaked. Add mon_put_kn_priv() to the out_mondata error path to free them. Fixes: ee4f0ec938ad ("fs/resctrl: Simplify allocation of mon_data structures") Reported-by: Reinette Chatre Assisted-by: GitHub Copilot CLI:claude-sonnet-4.6 Signed-off-by: Tony Luck --- Did I really need AI to help, no. But I wanted to see if it can at least save me from some typing. Here's the prompt I used (contains just as much typed content as this change!) Reinette Chatre reported a problem in rdt_get_tree(). If the mkdir_mondata_all() succeeds, the some memory is allocated by mon_get_kn_priv(). If a subsequent call in rdt_get_tree() fails, then a call to mon_put_kn_priv() is needed to free any mon_data structures. Create and apply a patch to fix this. Research a suitable Fixes: tag. Give credit to Reinette for reporting. Add a correctly formatted Assisted-by: tag with AI model version. Keep the commit comment concise. fs/resctrl/rdtgroup.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 5dfdaa6f9d8f..aad573b62fd7 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -2879,8 +2879,10 @@ static int rdt_get_tree(struct fs_context *fc) out_psl: rdt_pseudo_lock_release(); out_mondata: - if (resctrl_arch_mon_capable()) + if (resctrl_arch_mon_capable()) { + mon_put_kn_priv(); kernfs_remove(kn_mondata); + } out_mongrp: if (resctrl_arch_mon_capable()) { rdtgroup_unassign_cntrs(&rdtgroup_default); -- 2.54.0