From patchwork Thu May 18 08:18:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 13246279 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AC0FDC77B7D for ; Thu, 18 May 2023 08:18:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=nmXy9Cf6dXHbsAj8XVCxfGHebgVwjrkIfdovFTUSWLo=; b=txy9rZGHIPdpQf DNHWaAh/oUD313XQOzaPlv5XP0nvlXRKk+bb48oCcrWje8QvlgUFfIixOo3B1V0OWRXH6dy0/SLqT UvxTtFCfGPijkAUllYFX+J7OFeb5m2X0O0EXZz4QnRACDbd8V1s2wqcSseY5N9kcuq5MDu+qqyN5s WQwU30JQ94nj1HdtaRZFLwXVC0TKUazWyzQ8DRYE4/3K/MHgW1sdne0pqvjet/Gf0wN8pglfmhkd/ jkfM+Kb2ZJYUQIPAL9zK/cvtB8qtsC/0CdCOrIrpko8+EcSb3nYRtiBA+cZe/m5bMYF3ZPmU1J4lz s2DVFAvoLI3gLopPiG7w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pzYq4-00CK4O-0x; Thu, 18 May 2023 08:18:20 +0000 Received: from smtp-23.smtpout.orange.fr ([80.12.242.23] helo=smtp.smtpout.orange.fr) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pzYq1-00CK3p-1B for linux-arm-kernel@lists.infradead.org; Thu, 18 May 2023 08:18:19 +0000 Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id zYpup3mV8cjUozYpupl7Aa; Thu, 18 May 2023 10:18:13 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1684397893; bh=T4joMoRqF0rssfg793XkwK9lf4GR80yAVh0bfaxIbJ4=; h=From:To:Cc:Subject:Date; b=rqE/hZYJLqj2cF3pYy/AJGKuEPC6eHZakRG7ZprvxJq4R96dTge2zZ5yZmJCr9TkI 9D6PK77vw8sobGrE5A7+DqZ+VNVoXbkn1qr3s+WHIh+QBYdsHs0azN0eiUS8i7DhZF 5mZhC6nTgLgUBkN3PkyHCpW00F2Ag279PQYur7koLu+Eeu2ru7tBKBG3Zv4HJy9hA2 ywE43p8y1l3Jyo+N1iv20hujQ+SmcwQRE0FzQUhrqhoZx8F6B8OFpjbFDMufWsVe+X Kfhdo0P1C4eCQ5cylMeb2RZ635naSrdUhNP6Usmp7txu04fqX79c2qY9NJ+cKPG1E4 FZicBXYH7ehfg== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Thu, 18 May 2023 10:18:13 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Will Deacon , Mark Rutland , Neil Leeder Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] perf: qcom_l2_pmu: Make l2_cache_pmu_probe_cluster() more robust Date: Thu, 18 May 2023 10:18:08 +0200 Message-Id: <6a0f5bdb6b7b2ed4ef194fc49693e902ad5b95ea.1684397879.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230518_011817_563044_DD8D4BD3 X-CRM114-Status: GOOD ( 12.63 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org If an error occurs after calling list_add(), the &l2cache_pmu->clusters list will reference some memory that will be freed when the managed resources will be released. Move the list_add() at the end of the function when everything is in fine. This is harmless because if l2_cache_pmu_probe_cluster() fails, then l2_cache_pmu_probe() will fail as well and 'l2cache_pmu' will be released as well. But it looks cleaner and could silence static checker warning. Signed-off-by: Christophe JAILLET --- This is not a fix, because there is no issue. But in case of interest: Fixes: 21bdbb7102ed ("perf: add qcom l2 cache perf events driver") --- drivers/perf/qcom_l2_pmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/perf/qcom_l2_pmu.c b/drivers/perf/qcom_l2_pmu.c index aaca6db7d8f6..3f9a98c17a89 100644 --- a/drivers/perf/qcom_l2_pmu.c +++ b/drivers/perf/qcom_l2_pmu.c @@ -857,7 +857,6 @@ static int l2_cache_pmu_probe_cluster(struct device *dev, void *data) return -ENOMEM; INIT_LIST_HEAD(&cluster->next); - list_add(&cluster->next, &l2cache_pmu->clusters); cluster->cluster_id = fw_cluster_id; irq = platform_get_irq(sdev, 0); @@ -883,6 +882,7 @@ static int l2_cache_pmu_probe_cluster(struct device *dev, void *data) spin_lock_init(&cluster->pmu_lock); + list_add(&cluster->next, &l2cache_pmu->clusters); l2cache_pmu->num_pmus++; return 0;