Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp687645pxv; Thu, 22 Jul 2021 09:44:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzFBzkUIZ5EEnkEpCmoRugd9kOr6hL/veRdeupz2RB1vI7+0GVhMX7mHWYZpdsefjiX3cet X-Received: by 2002:a17:906:a2c4:: with SMTP id by4mr721068ejb.521.1626972281355; Thu, 22 Jul 2021 09:44:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626972280; cv=none; d=google.com; s=arc-20160816; b=V7+vw09C6DxpLO+CXFIGP55J6rPcicSC7oxXShNnl3RbiIrzuB54c4KKGqhRiDGnxl ZZu+YkU6245WgdYe/0WQf5qMzNaKRg6Y+sMWv895+VMuFqIltcwnujmVOUSMThqPGrip H7GbNJ4hs2ei8xpZ/X7y3fJ3d0x4IHc+xi3fYryZxsbKOhcxiAiabsDllWnsnoMq8wbC rjFpmQZsGRbNMdWuvFywySolT8YPGYQjif8Uq90Pq5/ltDFElt2YpZGJTFSm5ErW8OXv 7ekaoi6X1Af3TQX7rQ6AHUZXH1p4aIocvKnC0mGEO6aT15CJYiOUnjZYc+Glo2CFrELP gOPA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=tbO3lXaWXRTMFgLPdSUAprpM4mgx3WJczAdSICM/f4A=; b=G9WwWOJAoIG/SCeS9qaWJYKqpn+3FynqmmxcKsiwg5Wn3Rn6OCi8W1TodJXM5NgGWq UUjkFrhG6TgJwo2y0dn/E71kCEVrFC1auOvm3MjsSjCeBTRa5TapGQPNZ47PeSEStulw xptUt/xoS1qU3Ux5lGFWWD2f4juoBKVvHqmIBt9mBmDkdYOVDaliz+SRm24KQlFcB9aH p3NcsWwviktcFRkIfDna5WFkP+N/Nfb/pQFiGOsbU2KuFGlURJXYnPIYNE+H3oVfpahX Ni5kYyNoh5YlZse4sFxzei05WwaHw0LHxBRLiOpUWlVheht5bi1IdVUE9qqASGRThV2T 6++w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cKneVWlm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g20si22981689eje.712.2021.07.22.09.44.15; Thu, 22 Jul 2021 09:44:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cKneVWlm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233511AbhGVQCT (ORCPT + 99 others); Thu, 22 Jul 2021 12:02:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:35506 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233032AbhGVP6V (ORCPT ); Thu, 22 Jul 2021 11:58:21 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3D3FE61396; Thu, 22 Jul 2021 16:38:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626971936; bh=nUhw8pyc02sZXHr0c7qkcJ3bFdSd30YzlHR9IE0UXfg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cKneVWlmjVIvGzRUS5SE/w6QTH/rGxe3/xznq8DaSoMkqkoVo+IJneeYA8BSbb0Im NCqQf8/8QhNL93mK/yumDmsVQ5b8uccZvEWPNHnValVwe+HYdvinNxCGq0P0Xor3j3 RwQRcHPP2a/H8aHnL6xemJYCxdqq7uxILMz+lWjc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, gushengxian , Kan Liang , "Peter Zijlstra (Intel)" , Sasha Levin Subject: [PATCH 5.10 076/125] perf/x86/intel/uncore: Clean up error handling path of iio mapping Date: Thu, 22 Jul 2021 18:31:07 +0200 Message-Id: <20210722155627.212491230@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210722155624.672583740@linuxfoundation.org> References: <20210722155624.672583740@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kan Liang [ Upstream commit d4ba0b06306a70c99a43f9d452886a86e2d3bd26 ] The error handling path of iio mapping looks fragile. We already fixed one issue caused by it, commit f797f05d917f ("perf/x86/intel/uncore: Fix for iio mapping on Skylake Server"). Clean up the error handling path and make the code robust. Reported-by: gushengxian Signed-off-by: Kan Liang Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/40e66cf9-398b-20d7-ce4d-433be6e08921@linux.intel.com Signed-off-by: Sasha Levin --- arch/x86/events/intel/uncore_snbep.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c index 16159950fcf5..9c936d06fb61 100644 --- a/arch/x86/events/intel/uncore_snbep.c +++ b/arch/x86/events/intel/uncore_snbep.c @@ -3752,11 +3752,11 @@ static int skx_iio_set_mapping(struct intel_uncore_type *type) /* One more for NULL. */ attrs = kcalloc((uncore_max_dies() + 1), sizeof(*attrs), GFP_KERNEL); if (!attrs) - goto err; + goto clear_topology; eas = kcalloc(uncore_max_dies(), sizeof(*eas), GFP_KERNEL); if (!eas) - goto err; + goto clear_attrs; for (die = 0; die < uncore_max_dies(); die++) { sprintf(buf, "die%ld", die); @@ -3777,7 +3777,9 @@ err: for (; die >= 0; die--) kfree(eas[die].attr.attr.name); kfree(eas); +clear_attrs: kfree(attrs); +clear_topology: kfree(type->topology); clear_attr_update: type->attr_update = NULL; -- 2.30.2