Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp1809628rdb; Mon, 9 Oct 2023 03:54:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHjwDlIq8Moz4xHS3lAmt6tQAjURRYBVAJsSCVEXRDb1DdrIEiPW3WF0ZeRxhBgJHvRuT81 X-Received: by 2002:a05:6a00:3981:b0:68f:c078:b0c9 with SMTP id fi1-20020a056a00398100b0068fc078b0c9mr18495409pfb.11.1696848872649; Mon, 09 Oct 2023 03:54:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696848872; cv=none; d=google.com; s=arc-20160816; b=idZOO5yF1eXAxH5mOsQgdXS6e1FPl0gUS9GxmB7Jio+PEYxD0Q6xC8MvZ6Vu0eImEd uVrL5r1yj6qmJW4Y6v2atchfS2ca6FBhN8MPm8qDQhVyZ4kzRBcgNpBf1NdoOax3baOS EfPJtK76xPClODTQfK17bJRIEsww02UOPQOnWr1bhFP1Qo8bgnysYu6F28s3laT0Qvg8 ICODj2cXh2zUUljjkv4Aw1dGqWafLiB2dz1nMJbFCF0ZPBdcFs0BpNe6kSikRAF4rlua 1TtgrjO/TwlXwBWqad6RifrF+rRL1u5VUkZe/5LVCm3mKYScC3Qpo2eVDHU47N6n3YfP 8KCw== 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; bh=pSDP1UVqcvIm96jH8QClWm5EfneJZ8iv9LwzIVsuhEk=; fh=O8Y7T+ywS5mBDfThkbjC5AAPstuxM6EoFVNxBW5Bl3E=; b=Q6QYFt/pGfxPjKiqcygi/9JlNod4Tt2A1oueT31rQL+w+DC4XbAhtTTOIk8WgNojry xbidvgbyYK09imz9RkGh2UI4a1uD6tK2DphLLKuLlCbtV+WgQtZw+PyxNc27lzmkLKny SJLQYU/jkEX9vAEtyzuczff1Z8e8BwQmqfbJmIonSwy81FhBXX7PkJURMAbAKuzEIPxV KZoA7Cl7iYWiDYWNhNDHgwlpZmKnwJMOfDZuPTTbFkFfpihDnvoldxeWq1E8q9ItFmE7 yvjHxIsz5elNfb9tRxGzNtE4OMsUuECNnehjjcuVITIYL0Bd+1rwmfxZHjj/QtBMuka2 bkjA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id cn11-20020a056a00340b00b0068a53e61fdcsi7042197pfb.26.2023.10.09.03.54.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 03:54:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 5909680D7737; Mon, 9 Oct 2023 03:54:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346004AbjJIKyV (ORCPT + 99 others); Mon, 9 Oct 2023 06:54:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345877AbjJIKyU (ORCPT ); Mon, 9 Oct 2023 06:54:20 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10E448E for ; Mon, 9 Oct 2023 03:54:19 -0700 (PDT) Received: from kwepemm000007.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4S3wmF0GzYzkXtk; Mon, 9 Oct 2023 18:50:21 +0800 (CST) Received: from localhost.localdomain (10.67.165.2) by kwepemm000007.china.huawei.com (7.193.23.189) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Mon, 9 Oct 2023 18:54:16 +0800 From: Jijie Shao To: , , , , CC: , , , , , Subject: [PATCH drivers/perf: hisi:] drivers/perf: hisi: fix NULL pointer issue when uninstall hns3 pmu driver Date: Mon, 9 Oct 2023 18:50:38 +0800 Message-ID: <20231009105038.126040-1-shaojijie@huawei.com> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.67.165.2] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemm000007.china.huawei.com (7.193.23.189) X-CFilter-Loop: Reflected X-Spam-Status: No, score=2.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 09 Oct 2023 03:54:30 -0700 (PDT) X-Spam-Level: ** From: Hao Chen When uninstall hns3 pmu driver, it will call cpuhp_state_remove_instance() and then callback function hns3_pmu_offline_cpu() is called, it may cause NULL pointer call trace when other driver is installing or uninstalling concurrently. As John Garry's opinion, cpuhp_state_remove_instance() is used for shared interrupt, and using cpuhp_state_remove_instance_nocalls() is fine for PCIe or HNS3 pmu. So, replace cpuhp_state_remove_instance() with cpuhp_state_remove_instance_nocalls() to fix this problem. Fixes: 66637ab137b4 ("drivers/perf: hisi: add driver for HNS3 PMU") Signed-off-by: Hao Chen Signed-off-by: Jijie Shao --- drivers/perf/hisilicon/hns3_pmu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/perf/hisilicon/hns3_pmu.c b/drivers/perf/hisilicon/hns3_pmu.c index e0457d84af6b..16869bf5bf4c 100644 --- a/drivers/perf/hisilicon/hns3_pmu.c +++ b/drivers/perf/hisilicon/hns3_pmu.c @@ -1556,8 +1556,8 @@ static int hns3_pmu_init_pmu(struct pci_dev *pdev, struct hns3_pmu *hns3_pmu) ret = perf_pmu_register(&hns3_pmu->pmu, hns3_pmu->pmu.name, -1); if (ret) { pci_err(pdev, "failed to register perf PMU, ret = %d.\n", ret); - cpuhp_state_remove_instance(CPUHP_AP_PERF_ARM_HNS3_PMU_ONLINE, - &hns3_pmu->node); + cpuhp_state_remove_instance_nocalls(CPUHP_AP_PERF_ARM_HNS3_PMU_ONLINE, + &hns3_pmu->node); } return ret; @@ -1568,8 +1568,8 @@ static void hns3_pmu_uninit_pmu(struct pci_dev *pdev) struct hns3_pmu *hns3_pmu = pci_get_drvdata(pdev); perf_pmu_unregister(&hns3_pmu->pmu); - cpuhp_state_remove_instance(CPUHP_AP_PERF_ARM_HNS3_PMU_ONLINE, - &hns3_pmu->node); + cpuhp_state_remove_instance_nocalls(CPUHP_AP_PERF_ARM_HNS3_PMU_ONLINE, + &hns3_pmu->node); } static int hns3_pmu_init_dev(struct pci_dev *pdev) -- 2.30.0