From patchwork Sat Nov 30 14:04:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 846547 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2072.outbound.protection.outlook.com [40.107.94.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0B4881A08AF; Sat, 30 Nov 2024 14:05:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.72 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975538; cv=fail; b=al16TJ2/UKxESHRC4I3ZwuFiRa6wk2KKDUtOyC/wZgVLX06YeTl3hyjU8IEoMDdZPdjZp9vvOKUUDmnhMHVUliIjOTxOHkSa5mjmjEpcSfrDYk5pf+4h4QQgjHgsPxgQMeCgvlX4Er1Li7vqwy6lL+jY+pGb7zxot3tFMEkj41Y= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975538; c=relaxed/simple; bh=z0GlcC9vwRUmxS0LWl2nrqiX/2qAQj38IxksQe1F4C8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XQxHo14ignqSysoopP6Q+OqBwpOMLPkMLPOwEt0zpmIqSPKlxUL53gBKWZslTqr3Fbuu7C6KNdWASKgXW7Rx/iFb4wyxaUE0LL6FsiJAv3eWAE8Fepdxn56TDaWLYk0Z5DSOiYbyBheusUaKom6/7yMkeLzYRiU5iad6GgY4aLQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=LCvtUZf/; arc=fail smtp.client-ip=40.107.94.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="LCvtUZf/" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=J89VvtvmILQx6VHBAj35XWQmxyE24I86d4jJ9RQvSsq+smBiZcWDr7bZI+TZTNFMCTrjOpYlZFjy2FESFGES5TguuBfBhHWY5FxR5UhkoRI6UEMEck/Ps+7Xiz/hd9/eo1GKw5pSdqUP1i0eqAs8tI2NZnh62SOQYjLcnCIdpXvktUU9rGs9wNAr2TbqKJLhREgQWZRH5YftIyVZWciK8sOosLE90uLcPnC1Eqnn4zcEEBu6LfzLyXBPzYRB7odtdeSAYPNpnMS19p/XmWaC/91A/94n8py4rGpZdGr7uxYiHKHsuMGxO5VOEOwwKBVo9Elez6GlWj0p9Yg/aoi+kQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=Fbrw9w+y1t+fOwFGCAec/Yj7kmTgUhQgGzFW3WCgW90=; b=vJgGfRz/6pI+DqoqDvNz8bIU/zOni2CDHJWkgBIACl89mo4DaLruI86gdz66AnsMmJNuYEx8JkpfZonzK0TfD/ScTlCkr0oJOScswpGR/3IN3kLXk8AVmRrENIP7TS6PPpf6TOLyzOieisFFa5B0D1YRF9kLOaJSEsDf3gv7jGjuR8UcfEtPZPSCWsEc4hfzhzl3tks2Pc9L2ZdjN7xg6Bl1cGsajO1e3dowGPF61JS0VkH0OegqkNAP9HfkvDUmYevo9f95CG3MUazZfkPPjpQV96vqvHuQ0yaLAzuA14scnejvYzZyqejkT41goieFMzr17v7OXIg/W8pXpgfeAg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) 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=Fbrw9w+y1t+fOwFGCAec/Yj7kmTgUhQgGzFW3WCgW90=; b=LCvtUZf/HQtUj74QhTzqy2wHuEevh3+rVWEtQnjBKobWgi1Qyn37HUb89IU6lqI/K+C4lWxkS/0ZEjBqT6rRdchEYPlm2uhrS7uA/UvMZnylCfk8LJF9zKAkju0R80CBA0z/PVSu46F4MNz0RuzNcwbsvaElNI1AXU/Zs3CMMxQ= Received: from PH8PR05CA0006.namprd05.prod.outlook.com (2603:10b6:510:2cc::6) by IA1PR12MB7589.namprd12.prod.outlook.com (2603:10b6:208:42b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.14; Sat, 30 Nov 2024 14:05:33 +0000 Received: from CY4PEPF0000EDD5.namprd03.prod.outlook.com (2603:10b6:510:2cc:cafe::ad) by PH8PR05CA0006.outlook.office365.com (2603:10b6:510:2cc::6) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.5 via Frontend Transport; Sat, 30 Nov 2024 14:05:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000EDD5.mail.protection.outlook.com (10.167.241.201) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Sat, 30 Nov 2024 14:05:32 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sat, 30 Nov 2024 08:05:28 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v8 06/22] ACPI: platform_profile: Move sanity check out of the mutex Date: Sat, 30 Nov 2024 08:04:38 -0600 Message-ID: <20241130140454.455-7-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241130140454.455-1-mario.limonciello@amd.com> References: <20241130140454.455-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD5:EE_|IA1PR12MB7589:EE_ X-MS-Office365-Filtering-Correlation-Id: b4d2d5b8-35e6-43d7-3db3-08dd11480de2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|7416014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?XYyjPB3Qw3fNjtjxpML9Gd3BE+Ngmtz?= =?utf-8?q?nZVSRy+KwmHPC2TXeDFcxgQfEZ1oUrSClwFjMtaycUHWZ4qf4Ct44CbPBWkOnN7TV?= =?utf-8?q?VmYnGFvvrCuXRd2gSJHUOXB5ThPjM8io9uPtUei9etjXEIBY/0B2hbQYR8yKoG0KB?= =?utf-8?q?tpC59eFYtGRV19dKrjVMDpdgz02ZN0HXPlnW+kzJwgPn8ryWVDi/TnW/Z01ntYDia?= =?utf-8?q?hPiNCY/cdBg1SurH4m9ZqJ2euxmHdfrlzNpJxnlxIBza9++slhpxnZa8Bty8wGJzP?= =?utf-8?q?nPATXsaye1TSwUBhr1hdJsxUdOx01sNxOXk1k/4OjzcVZMy7K719nUJfR/f60tUhq?= =?utf-8?q?s9PkSG0X2rZGw6lgedTl7Xs9GUGyNkjg62bUbv8nMGDx4ZcnTlnHpwGL+Wfb3ux2g?= =?utf-8?q?oVWZO+EB8n0PaGqT9GqXIR4R45b4MNaI3J9SR41ZWBKfKJHAsS5Zh68svqiHlsAV3?= =?utf-8?q?g4xs0Dqr/SXjlyN4dS5DjaU5jXywdzx5Fe6hJZwO4k6BkxZ1FMrW9gYZ2SNykl2Zw?= =?utf-8?q?SLrIDcCxwwDEPYdvKHnHNWTW5BBChtRuj6WNEmo40UIFDBOBjO70UeOxPR+4pSm8Y?= =?utf-8?q?HplXMB+qW6Os5+nscxGeAQimFsTbEja8R+FMF7DD6cOKkrSentVPX4XSeI0vdqzG/?= =?utf-8?q?9l8MItl5FOYABPMs+reueRaQqb0AZCB6C/8UuE22JLMU4V+aVDx6WioyZgEn4viWr?= =?utf-8?q?o+iY0NadwMaFix1Q+Ha3sWYsP9/kg29dT/stSEHkfBsvs5uISacvddhV6UZIVyiQL?= =?utf-8?q?5gV3IWp91pB5lOcSxj8S3I5Iur7wdOXugr5wSopdD3AwkJB1/Oq90ZoAcD+yrjT9d?= =?utf-8?q?vIS+vHpnYoHw6Hos3aOmJiSxykjs8aq95KSSHYn03geNAWNXoz1k+gpeyDzARG1PO?= =?utf-8?q?yjcD4fA9LRf6bwW4fuJgbzcizfo/EYjH8q0v0N5JsI3Vhr2+JqT3ltZVq2Z6ijdjO?= =?utf-8?q?TWUuMymSaUhIUQo6j+8Gm4NmtLl6nkfG4G0W5ItZ7cbNgW3Fy8GDeH2+zoko6PpTo?= =?utf-8?q?udBNBw1OolVvaEVk/HArDlY4onRdjZM8zQVQEqIW81tbOnFvQMZLtkUMqADxxM2C8?= =?utf-8?q?A0eBusMV/ks/Rxu7HWOVJiF6bCCWeQTlj/gc71f/wqGxLYS3cNTqc2sYfdaQUWdX4?= =?utf-8?q?2JIQDLTBLUJ+6tTM1KuUAR4sTXY1+jP2bc7rbGXwQSgA96Gc58Xa8eYFyk6+NjuZ6?= =?utf-8?q?hj1rF7K7MLOvp0uE0ddHZ3JiPa6FkOlBpelMO7emuMc1frWiGzy30K7KK4fsMOXRC?= =?utf-8?q?k4QePTqJZGTH32OmOIsnB4uMay3GSA6mwCvydLjv+opqRtcNlsTsh65MnRVniyPOY?= =?utf-8?q?OiVOlpnPbUW4rOZaismjK7BWr7khp3dYHTU7if5gWqL9EzSajGsU+rbwye3jaRVxG?= =?utf-8?q?g7uej+1fQaV?= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(7416014)(1800799024)(36860700013)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2024 14:05:32.3007 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b4d2d5b8-35e6-43d7-3db3-08dd11480de2 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD5.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7589 The sanity check that the platform handler had choices set doesn't need the mutex taken. Move it to earlier in the registration. Tested-by: Mark Pearson Tested-by: Matthew Schwartz Reviewed-by: Ilpo Järvinen Reviewed-by: Mark Pearson Reviewed-by: Armin Wolf Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 927a2f7456c9a..4f5623fc27c09 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -179,6 +179,13 @@ int platform_profile_register(struct platform_profile_handler *pprof) { int err; + /* Sanity check the profile handler */ + if (!pprof || bitmap_empty(pprof->choices, PLATFORM_PROFILE_LAST) || + !pprof->profile_set || !pprof->profile_get) { + pr_err("platform_profile: handler is invalid\n"); + return -EINVAL; + } + mutex_lock(&profile_lock); /* We can only have one active profile */ if (cur_profile) { @@ -186,13 +193,6 @@ int platform_profile_register(struct platform_profile_handler *pprof) return -EEXIST; } - /* Sanity check the profile handler field are set */ - if (!pprof || bitmap_empty(pprof->choices, PLATFORM_PROFILE_LAST) || - !pprof->profile_set || !pprof->profile_get) { - mutex_unlock(&profile_lock); - return -EINVAL; - } - err = sysfs_create_group(acpi_kobj, &platform_profile_group); if (err) { mutex_unlock(&profile_lock);