Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp805398imm; Mon, 2 Jul 2018 23:44:38 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKgVgpRJo6BVyv52LZlAEk+IqwQUuX8HSaRb2v44s08VjiNS0vUFGjYBhKJDSZoo1Tds8w1 X-Received: by 2002:a63:bc0a:: with SMTP id q10-v6mr24335014pge.70.1530600278361; Mon, 02 Jul 2018 23:44:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530600278; cv=none; d=google.com; s=arc-20160816; b=vTjaFMqa+k/Klfb2eCVoDtjYg6MB+OQfRHiCNpG92bMjpomTqmAvtofFeL9MY/4DQb fka31yLLzvFBaeoqgjgFBnJDezChPWApgECjnRiRBz+7Yz3V8fk0Jwd3edbXX7LTlDOQ nJFbsaluiROqrEYQNzCxK62/c1s5PadmVuQL80KjzVbpofX6hinnLNiMK047lgoccny/ oHQ59TcGVNvSfoTRUZ2lhMeDgFmDDbQFSrBlbzsXynYY55HMPMreu2eFaFXXu7ny0AVz oiDcebd/vF70g1sEifszoKCcyTX0Vs7Tf7a8L5dYpYRW92I1hmHQCT4n6jlmlgaoUZP1 gwrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=ASLDogmB+hsmAPXdt2BAOMrm45CE7cx+Ze4bmeQfa/s=; b=PMcqZywKwufJ3hQsbtCKfH+DljYOdO19ugzkcbSU3KnKnk1BkIGFl4Gt2blkyrXlbn gfEpuBxwvu8G3cdpyiI2SsG1HoPX2WIjTjr17Bj6UB2rAMhcm/urNLmGgWFDaU/18DOX 2mzKeydyO7cU9RR2vjQPCpiAtesF3uUrZVjs6PtZNA4M0xzMxtJLb+hyc0+o6UXPqtSC y6jdNzVFKbLoOfafjQoGFpcjfDwBCrVzryVx1qU+NfDZCJRu3402K/DiPYWhrTVLWv2q jxinIafQptuQLIOnk5HeYkEUZ4FFLTMbP/4jXPr/3mEecVLCIKa0oewJa0dC1gSxCsw4 mnCg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v18-v6si425453pgl.171.2018.07.02.23.44.23; Mon, 02 Jul 2018 23:44:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753818AbeGCGnf (ORCPT + 99 others); Tue, 3 Jul 2018 02:43:35 -0400 Received: from terminus.zytor.com ([198.137.202.136]:33249 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753557AbeGCGnc (ORCPT ); Tue, 3 Jul 2018 02:43:32 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w636hQc8182654 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 2 Jul 2018 23:43:27 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w636hQF6182651; Mon, 2 Jul 2018 23:43:26 -0700 Date: Mon, 2 Jul 2018 23:43:26 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Reinette Chatre Message-ID: Cc: tglx@linutronix.de, mingo@kernel.org, reinette.chatre@intel.com, linux-kernel@vger.kernel.org, hpa@zytor.com Reply-To: mingo@kernel.org, tglx@linutronix.de, reinette.chatre@intel.com, linux-kernel@vger.kernel.org, hpa@zytor.com In-Reply-To: <49b4782f6d204d122cee3499e642b2772a98d2b4.1530421026.git.reinette.chatre@intel.com> References: <49b4782f6d204d122cee3499e642b2772a98d2b4.1530421026.git.reinette.chatre@intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/cache] x86/intel_rdt: Fix cleanup of plr structure on error Git-Commit-ID: 546d3c74277398a3d76d059bd2db47186bb47fc8 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, T_DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 546d3c74277398a3d76d059bd2db47186bb47fc8 Gitweb: https://git.kernel.org/tip/546d3c74277398a3d76d059bd2db47186bb47fc8 Author: Reinette Chatre AuthorDate: Sat, 30 Jun 2018 22:03:03 -0700 Committer: Thomas Gleixner CommitDate: Tue, 3 Jul 2018 08:38:39 +0200 x86/intel_rdt: Fix cleanup of plr structure on error When a resource group enters pseudo-locksetup mode a pseudo_lock_region is associated with it. When the user writes to the resource group's schemata file the CBM of the requested pseudo-locked region is entered into the pseudo_lock_region struct. If any part of pseudo-lock region creation fails the resource group will remain in pseudo-locksetup mode with the pseudo_lock_region associated with it. In case of failure during pseudo-lock region creation care needs to be taken to ensure that the pseudo_lock_region struct associated with the resource group is cleared from any pseudo-locking data - especially the CBM. This is because the existence of a pseudo_lock_region struct with a CBM is significant in other areas of the code, for example, the display of bit_usage and initialization of a new resource group. Fix the error path of pseudo-lock region creation to ensure that the pseudo_lock_region struct is cleared at each error exit. Fixes: 018961ae5579 ("x86/intel_rdt: Pseudo-lock region creation/removal core") Signed-off-by: Reinette Chatre Signed-off-by: Thomas Gleixner Cc: fenghua.yu@intel.com Cc: tony.luck@intel.com Cc: vikas.shivappa@linux.intel.com Cc: gavin.hindman@intel.com Cc: jithu.joseph@intel.com Cc: dave.hansen@intel.com Cc: hpa@zytor.com Link: https://lkml.kernel.org/r/49b4782f6d204d122cee3499e642b2772a98d2b4.1530421026.git.reinette.chatre@intel.com --- arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c b/arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c index 1860ec10302d..8fd79c281ee6 100644 --- a/arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c +++ b/arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c @@ -290,6 +290,7 @@ static void pseudo_lock_region_clear(struct pseudo_lock_region *plr) static int pseudo_lock_region_init(struct pseudo_lock_region *plr) { struct cpu_cacheinfo *ci; + int ret; int i; /* Pick the first cpu we find that is associated with the cache. */ @@ -298,7 +299,8 @@ static int pseudo_lock_region_init(struct pseudo_lock_region *plr) if (!cpu_online(plr->cpu)) { rdt_last_cmd_printf("cpu %u associated with cache not online\n", plr->cpu); - return -ENODEV; + ret = -ENODEV; + goto out_region; } ci = get_cpu_cacheinfo(plr->cpu); @@ -312,8 +314,11 @@ static int pseudo_lock_region_init(struct pseudo_lock_region *plr) } } + ret = -1; rdt_last_cmd_puts("unable to determine cache line size\n"); - return -1; +out_region: + pseudo_lock_region_clear(plr); + return ret; } /** @@ -365,16 +370,23 @@ static int pseudo_lock_region_alloc(struct pseudo_lock_region *plr) */ if (plr->size > KMALLOC_MAX_SIZE) { rdt_last_cmd_puts("requested region exceeds maximum size\n"); - return -E2BIG; + ret = -E2BIG; + goto out_region; } plr->kmem = kzalloc(plr->size, GFP_KERNEL); if (!plr->kmem) { rdt_last_cmd_puts("unable to allocate memory\n"); - return -ENOMEM; + ret = -ENOMEM; + goto out_region; } - return 0; + ret = 0; + goto out; +out_region: + pseudo_lock_region_clear(plr); +out: + return ret; } /**