Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp791335rdg; Fri, 13 Oct 2023 00:44:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFihDRrr3zCxxVGxcviMkcfFzutUPKVOCFSjlRGbcORvZX4/ZW2CbBRCIAxbdQz7QNfp/J4 X-Received: by 2002:a17:90a:1a0a:b0:27d:2cfb:321a with SMTP id 10-20020a17090a1a0a00b0027d2cfb321amr2261484pjk.32.1697183056641; Fri, 13 Oct 2023 00:44:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697183056; cv=pass; d=google.com; s=arc-20160816; b=0WxnneGhNM4G3ub1ZCImZeh/tCc8aGyYXAC659+Bdmfndjc2FNttNFExCUWk6zNYYg 7QEWyQEAkhTmJbxyd0cQaQSENHQzPqjc1lSxJDFMndikqpV0JSCIPfvHlE6BYtlFtzR5 2it0cCmBjKNDaVy0CDmBgKlAC5Gfm7XxyO3ybiYCnELFGl9mlsjkmiJY/yj6UwHSk9FS E1c6fYIHpxYuKzq5PPzlaAuIt4oEkbh/QBK2R9HAsm65DMgWmpRHY/3xFeH0dAoreqxV QaCsI15ZtHe6Envsxd0otCCyxgeK55jpAlDDNw8aEY2qMezQ7pQJ3J54MScwMtANu/hR 6yMw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:date:message-id:dkim-signature; bh=m4XyjT3jl32qUN2kicNUfIneW81E524qgY3JLMf5atE=; fh=0LjiYIDqvWBPSWv5Y3VspgHLYXQqYM2tj+fPjy26sIs=; b=iHDE56m+6SQ+s+AjDDn1OLg/mh5cDOyoni5pic8TkqsmIVwFFretzVJnVpGRa16pS5 mn06OZWX4jZm/9v+DVK5k3EY8+iyWKnF7MOhsVdwB4OR9hMxtiC3NYa7J+3ONMm6IkJS E/vGTQswrhk0QTYyX5UXXqkwxaLCeqcbLAg0RGVrjrGMII0ysGYD8lvrCGJ4NEnoiV5D 6YZCWqPw2fQVnzsyDKLs3iyS/QhC1aNZagbHB9IOxH6JFap/ouY92V5sMfJFkRJ/k7tV SJ9h6n3W39RZEwAfz+QX8wZxf6qUxeNAytVUF844+kxobgVOwa/5hL80KDTgH9YHkr9u qEdg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=lqzShgHu; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id j22-20020a17090ae61600b0027ce7a59589si3959739pjy.142.2023.10.13.00.44.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 00:44:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=lqzShgHu; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 485728208F05; Fri, 13 Oct 2023 00:44:14 -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 S229930AbjJMHoG (ORCPT + 99 others); Fri, 13 Oct 2023 03:44:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229886AbjJMHoF (ORCPT ); Fri, 13 Oct 2023 03:44:05 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2083.outbound.protection.outlook.com [40.107.223.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C668983; Fri, 13 Oct 2023 00:44:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DPpQSWB3JxZE1ghDVf9htDzjuvc10Wj1Qh/66ESColNbh4rgILddLydUKUyK3y6NztCiiYYgM95ycwXvcxu7qR0VjQszJJBlCyEBBt7nzY5/MoXq82uRgeJr19lY8YwDfqVIthAlq2XCx9bvIhPJVMlk9qmjALRA7X+4vbNidkEq/tLif8HI5cELNBW0RybqS9qQPnimXiqKE+rAn9NHa1gXn9W1KLUWULXV6RNvnixEA2oWtX7RWPqy4G1m666qnCcH53SJKorJCKaw9D7h+If0piojOaFsH3AInTo4JETZlBawqd1ctKdNsrU8V7UEZEHEQBUnTujGXqNkkkcZiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=m4XyjT3jl32qUN2kicNUfIneW81E524qgY3JLMf5atE=; b=FFt1eOFVapXdqmyL37evB0EmGn54eZ2nTlCCG2lRlYGJZY6t4AyUEJjvsTBz67+cRp6fG9P52xblCOGAj9jJVyOVVT1F3CGSl8dR9yOHdkfgdgHHYmIm1jnnrYVH0/DOsiUpfjmUbjkuXzq0sV/Zz0H/1kdSTElTSHc8zCEYJOi77b3orJcPw7kHcxOGaS3SKPl2HM+p2iQHlC5Lb862/xO59DtilFkYN90oDh2DZmjbmNxPl6s74qVlQx1nfgl4WiS9voATOk6aouH1MgHo6li2cPQmwxcnk8/FToWbnkXk24lJRm4014pi0pP1pFiFx0xrVJgQUNg88GAu4mev9g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=m4XyjT3jl32qUN2kicNUfIneW81E524qgY3JLMf5atE=; b=lqzShgHuxrv8wwjE2SMa8M58D5tn8kMqLJLy30q49dh/0olAZ3EHf7IyNQ7pVXv91o3CfHQXZ67umcVqo26yJ6oq8YYELIB6InkSBShzgRLUJdfwuacVnaQ4FkgzJXwaRQUmIWpDE8kVbsbxGclFvk2fiiw9rQ/ESkqXvsRUzdo= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from PH7PR12MB5712.namprd12.prod.outlook.com (2603:10b6:510:1e3::13) by MW3PR12MB4443.namprd12.prod.outlook.com (2603:10b6:303:2d::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.45; Fri, 13 Oct 2023 07:43:59 +0000 Received: from PH7PR12MB5712.namprd12.prod.outlook.com ([fe80::ec22:9c20:11d9:e840]) by PH7PR12MB5712.namprd12.prod.outlook.com ([fe80::ec22:9c20:11d9:e840%6]) with mapi id 15.20.6863.046; Fri, 13 Oct 2023 07:43:59 +0000 Message-ID: Date: Fri, 13 Oct 2023 13:14:04 +0530 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] perf/x86/amd/uncore: fix error codes in amd_uncore_init() Content-Language: en-US To: Dan Carpenter Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Thomas Gleixner , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org References: From: Sandipan Das In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: BM1P287CA0009.INDP287.PROD.OUTLOOK.COM (2603:1096:b00:40::17) To PH7PR12MB5712.namprd12.prod.outlook.com (2603:10b6:510:1e3::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH7PR12MB5712:EE_|MW3PR12MB4443:EE_ X-MS-Office365-Filtering-Correlation-Id: 961196c2-1c15-4242-8581-08dbcbc02933 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kX+KF7yIV/tJPOojhpOyG3mdc8lvQ+1PiZZt+cvwNudIw39eT+7GSXCTqnOb6sXnMbirxsRVSkv5Jhjp6BLEmxJvJExhJlszgVC/9iLg1qVREWbhQ7Sx7s7S8MPbhe2QqxTnOFuwb0minRkQYLShXjhnzMR7vtv9I5xzWB07nwJcN2PN9q2lVVvYamuPirDFCQ7wcx3NzYB0K6Rvo9Ze4EzXDhIumRQ/GfPWYPnjMKXfYpc8Tv4ikGTtC+jfBfMmV9+LTYnXxqBFn7S7kmPqCcUtTxbmc9FGrdHiC2VdS352WK0XX0WL04CuFPEVnGuqgGnvkAM6JoeP6My76gVO1sd0g566H8I5F+NP+AvofMxKk7qZ7AH19d5YJgDxZAJfbdOQzAS+EgVyG6cZybrjcjKABqqNAyT3f65KabHf35LEGxHfN7e/bZw9Ps6NvfFW/Kb7hnYlFm/OwwxaHt4uVRkRjeswdBVvXZWRtbSkaxq0MGdLmHiXkMTg4MXfpjLyzolj3z9T4Tj67yu/gbmGaj3unD9HPVodcj3wnBnBA6r8jhuPz9WbqAhZWNjjM/vIB7rQL0/lW0C2wa9X2ixQ1yNQC6qvlHhkEANr1xWTNpor6WvQENWNwM8me0zrEBPtJRP9W6srHQM77vFjtaxxsA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH7PR12MB5712.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(396003)(376002)(39860400002)(136003)(366004)(230922051799003)(186009)(1800799009)(64100799003)(451199024)(2616005)(7416002)(6506007)(6666004)(53546011)(41300700001)(2906002)(66476007)(66556008)(66946007)(31686004)(4326008)(44832011)(26005)(478600001)(5660300002)(6512007)(6486002)(83380400001)(316002)(6916009)(54906003)(36756003)(38100700002)(8676002)(31696002)(86362001)(8936002)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?NmZySXJPeHVCU0s1anhQYmxPeXRmY1dMU0pzeGJEY3Z5TnlqalVlOHhYLzRB?= =?utf-8?B?MUNscERTMXpkSk1GNEVhRjBRWk9hd09sMUo4Y2JQUzVlUnVyRmZsY1ZONmM4?= =?utf-8?B?L3lkZkZjU29qcXNRcE1JbTh1dWhPU1dNNUUwWUpxVXJnMnJxV3FMTGRKNk1q?= =?utf-8?B?Y0N1QklnMkUrWmFIZjd2Skl0R21obnlmUGdTLzRFRnVFOEEvejZjOUlJNHlt?= =?utf-8?B?Mzlsc1lHdjJvVnZuUTNqRklpM1hDWUNLbnpjTis5L2dnZUxuRkwra3NVN2xy?= =?utf-8?B?eUU0bytaTlRDMWt4YUVzcVZxeVpUMG9Ob3RIWjlrYWJOZU9iMlJZZlBjamNr?= =?utf-8?B?eEdaWlVRcTVaUUZobzJ6bjJQcUFTdFN5R29sa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2-1c15-4242-8581-08dbcbc02933 X-MS-Exchange-CrossTenant-AuthSource: PH7PR12MB5712.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2023 07:43:59.2085 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 8LUug/4goWeW4VdaW8jHJbisvxvcosUWNwmWRp4LbiXO8e6Wmm9yvLMeKuD54No5AwUjfvPJXwb2O3e60h5tIg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4443 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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]); Fri, 13 Oct 2023 00:44:14 -0700 (PDT) On 10/13/2023 12:48 PM, Dan Carpenter wrote: > Some of the error paths in this function return don't initialize the > error code. Return -ENODEV. > > Fixes: d6389d3ccc13 ("perf/x86/amd/uncore: Refactor uncore management") > Signed-off-by: Dan Carpenter > --- > arch/x86/events/amd/uncore.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/events/amd/uncore.c b/arch/x86/events/amd/uncore.c > index 9b444ce24108..a389828f378c 100644 > --- a/arch/x86/events/amd/uncore.c > +++ b/arch/x86/events/amd/uncore.c > @@ -1009,7 +1009,8 @@ static struct amd_uncore uncores[UNCORE_TYPE_MAX] = { > static int __init amd_uncore_init(void) > { > struct amd_uncore *uncore; > - int ret, i; > + int ret = -ENODEV; > + int i; > > if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD && > boot_cpu_data.x86_vendor != X86_VENDOR_HYGON) Thanks for catching this. I see that 'ret' remains uninitialized for cases where the hotplug callback registration fails and was thinking if the following is a better fix for this as the reason might not be ENODEV. diff --git a/arch/x86/events/amd/uncore.c b/arch/x86/events/amd/uncore.c index 91f01d6c8f7d..7d768dd01522 100644 --- a/arch/x86/events/amd/uncore.c +++ b/arch/x86/events/amd/uncore.c @@ -1039,20 +1039,25 @@ static int __init amd_uncore_init(void) /* * Install callbacks. Core will call them for each online cpu. */ - if (cpuhp_setup_state(CPUHP_PERF_X86_AMD_UNCORE_PREP, - "perf/x86/amd/uncore:prepare", - NULL, amd_uncore_cpu_dead)) + ret = cpuhp_setup_state(CPUHP_PERF_X86_AMD_UNCORE_PREP, + "perf/x86/amd/uncore:prepare", + NULL, amd_uncore_cpu_dead); + if (ret) goto fail; - if (cpuhp_setup_state(CPUHP_AP_PERF_X86_AMD_UNCORE_STARTING, - "perf/x86/amd/uncore:starting", - amd_uncore_cpu_starting, NULL)) + ret = cpuhp_setup_state(CPUHP_AP_PERF_X86_AMD_UNCORE_STARTING, + "perf/x86/amd/uncore:starting", + amd_uncore_cpu_starting, NULL); + if (ret) goto fail_prep; - if (cpuhp_setup_state(CPUHP_AP_PERF_X86_AMD_UNCORE_ONLINE, - "perf/x86/amd/uncore:online", - amd_uncore_cpu_online, - amd_uncore_cpu_down_prepare)) + + ret = cpuhp_setup_state(CPUHP_AP_PERF_X86_AMD_UNCORE_ONLINE, + "perf/x86/amd/uncore:online", + amd_uncore_cpu_online, + amd_uncore_cpu_down_prepare); + if (ret) goto fail_start; + return 0; fail_start: