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: 95696 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp326224vqo; Thu, 18 May 2023 01:23:18 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4N9TzRDa31FbgYkUoU0eSV/RiXF8Bk1NKNi0wrrkm0ORqMgDoAk4wSJ/UJAxOJrU/+NXSL X-Received: by 2002:a17:903:2581:b0:1ad:e099:fc04 with SMTP id jb1-20020a170903258100b001ade099fc04mr1629440plb.38.1684398198560; Thu, 18 May 2023 01:23:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684398198; cv=none; d=google.com; s=arc-20160816; b=bOgL2dySz5TPkXyC1AOoPUTAuv+5LJdH91byHRWrWLTLlSbarzNTWF5sYhSPVtdtB2 2l/wLMXU6hNp8l4jHGSzKiUPbiWfyq+UJdMZWPaqs4IjY2cMH1l/FGK91sd7lT10jJWq 0C1tlpDTDsl5f2klhN+prnJ4T/KGwKhMhGWBImvKEEs8ZO82DP0T4uN5TQmR0A77TsG8 qIIIH42vmcuu2v/8ypw8PJY5RAUQoUsnO5M2HQDpIRse8E4bdbvKuxgi/H9fLZq8z04s Fbfvju/KZzuS+u7lNmfLVkkWujBZI/DZjXYN+ZVnZVUA6adOOqvY4tQ6aSX+IwupUGLp KtbQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=T4joMoRqF0rssfg793XkwK9lf4GR80yAVh0bfaxIbJ4=; b=WxngIFRACr5cEfMdKIm2E92FdWQXqWKd+8Vh9EhSJ6PxDw7v72WNVSOwxj2/8momoP N1SgSrtxNlsNje9kxYbHbu2pZY2P8pf5d5vKDyYbQx8X8jaBNj6igIG9KGheaGRJ7/Ck 0j7zZJYaanfXCtyLyOKmMqonNSpMNnxC4yMI0baU4UVLcNdPszJTvEDfXbscGkG7UR76 iHohm1Qso40iOuHzlIIwzyDv3zy5sCDbV6x+gF++MoaOWn2u0ylfWqjNQr/dPBhitwbm lQoOSO+hk7YJlHYJ+ukm+zOyNX3T9HZRQb4qSkzBKGCymT8WO2w8p4XvARPBOl6JH2TW CrlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b="rqE/hZYJ"; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g9-20020a1709026b4900b001adec0d4391si808227plt.48.2023.05.18.01.23.06; Thu, 18 May 2023 01:23:18 -0700 (PDT) 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=@wanadoo.fr header.s=t20230301 header.b="rqE/hZYJ"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230031AbjERISW (ORCPT + 99 others); Thu, 18 May 2023 04:18:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230017AbjERIST (ORCPT ); Thu, 18 May 2023 04:18:19 -0400 Received: from smtp.smtpout.orange.fr (smtp-23.smtpout.orange.fr [80.12.242.23]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3776E49 for ; Thu, 18 May 2023 01:18:15 -0700 (PDT) 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-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766219525454460245?= X-GMAIL-MSGID: =?utf-8?q?1766219525454460245?= 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;