Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp631760rwd; Thu, 18 May 2023 01:30:20 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6H0IgOUS5u8/mzj24hAfohnLZzz5H6nXx/w8l6ZX2tuiEGIKGMLsjw7mo/GuBaOlAcJPJ7 X-Received: by 2002:a17:903:2303:b0:1ab:1b45:7972 with SMTP id d3-20020a170903230300b001ab1b457972mr2561378plh.0.1684398619815; Thu, 18 May 2023 01:30:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684398619; cv=none; d=google.com; s=arc-20160816; b=kXIlb/I/pVKIxRhI7mJ4nJliZlArhsQ/0Sm/IXNGGRnTryXXYLURz5XDqQX3PKIQ0V zwDjUr9PFDetiDWK7LOUh6y+9r0CKWGjxxksOVs97BEXaI9ZPNUmhc3HAc+Va18pFkuP eq70tQa2GguN0bKFqmHN56Gb/Mx3HgfClbve3DaW0un/06jkUHFnMxg5KJV8l8CiTk17 Vy7MqR3+dSHtNKiL7h9lVGE8OU6+8QP+rTkxh0ZBNSZVaBOaQBF6gXqz+N4lf9QFIo+G Wn3/kmYKO/NVVgUNs9RQBcZprjKCB0YCQsHYoc7LDVe/WM3DJ8aPacq4TJP8kfz2o6gh gMlQ== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h24-20020a17090aa89800b00250a2e130ecsi3777859pjq.87.2023.05.18.01.30.07; Thu, 18 May 2023 01:30:19 -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 S230029AbjERISW (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 Content-Transfer-Encoding: 8bit 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 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; -- 2.34.1