From patchwork Tue Nov 5 15:33:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13863083 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2043.outbound.protection.outlook.com [40.107.94.43]) (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 62FF0146013; Tue, 5 Nov 2024 15:33:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.43 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820823; cv=fail; b=roODfQo6V/LBWMWGviPV5yIYAZcLa7x9D/4Da9Q4dRiNgM+UR4zZPejR0xrYPfmeIpnznKWTappgezQK11i5++WBEXwyN1XeKDYChlm9jxXa7S8KHDalmocK6muiyejM4XmPbyHCJdPlPAazCk16PjMpfHV8p6tDDFHDEFhFC+M= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820823; c=relaxed/simple; bh=coqx1ADwMrtXqO17eBAIJiGtY0S3w4Hi1a9kzpKViqo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZIbnnMysoFNQrP8xktuYpy58m7elMZde3iLYqnhR6YXHottRhwhxUERKgWogzZ/BrcK7zsKprb58zNIzNw89SSxy91TiGqDaBiNt7ijJbTNaDhwJrT7bMZdrZ/zYpNEkL1TGSa11nyg5XuGRMCbHyDCWZav9m7AeLIYk6UK1oIs= 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=uxuHjSst; arc=fail smtp.client-ip=40.107.94.43 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="uxuHjSst" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tUV+yMW+v50dewUWpC6Z7HviLSDYEMVy64xTuOkqXfPM3gWbI8Eb4Hy/61hA7jbvZflYfGwEM93nK6ffUpZ3vbTxSjqWVv/AOufSqjIYynosOUzrdQsR6vcRWbknjmq3gNOuzNZO2JAXRoIzrxzCGozAzlGcl52FeXD7xdjxlg9cbhF3FN0vWfNzWmAsOLvv4i55UdzbKcX17pNBRRg2Fu97bvdl4kCoOXlJawDncFejtTJwoDoVjUaFkNlaqZo92L/SMkFQs0Qmcugs6yNOJ5DIwUqDqIS5FW8nXj0byRpbsKoaEpqNhuOd2O3VZKORxe88DPMDnT1wEw5EqjryiQ== 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=NgdRMEm5b7ecUIgJRgBzczX2TCGPfumhFWdIRNlizFc=; b=zW6zxLHRPaEowdqX1idz2imKqkiKr2lwpAT/0KjYQNy+RAFJVUv2UODqnMdNetFzURkHlJegfoafHUmUb892kgoALUTqKR4lzTUl5UKZTn4esie7ETYRcbYgnO4xD7Y1ANaBo5QGIeXklvuOHzTj65Xbyv/O9106MzF0NOs8O2lUkM4OtNV+3Ha8RwAL6+GqjMc+FLj6lMaVo+t1tXw92BiITnCcr7W+kbRmfJ3G4j3jS2su7L05UZyel/w+NVLnF9xcL3eFHPQxY4u7ix2sEmn3EsEOmp7XZNg08ZL/rBC60pqFKxwxRqIIZmkrLQKPBKUKBGlY80781aUDAL5vSg== 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=NgdRMEm5b7ecUIgJRgBzczX2TCGPfumhFWdIRNlizFc=; b=uxuHjSst+FHZRO9Y7cwG21Xjy4+2FvmHpWdeUx7zwEwH3D0RdtHVo55JpIKvtXZVhlPhBNyFND8wCXOUXHyYeXw/91z4DdP0UIfizSalySnQHeZ9gsxxG7cMhnbJPhg+aTV+HPOG92ZFhaqti+A/UiICT8MTTw1yQy7oBaitS7U= Received: from MN0PR04CA0028.namprd04.prod.outlook.com (2603:10b6:208:52d::27) by PH8PR12MB6795.namprd12.prod.outlook.com (2603:10b6:510:1c6::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Tue, 5 Nov 2024 15:33:37 +0000 Received: from BN2PEPF000055DF.namprd21.prod.outlook.com (2603:10b6:208:52d:cafe::cc) by MN0PR04CA0028.outlook.office365.com (2603:10b6:208:52d::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.31 via Frontend Transport; Tue, 5 Nov 2024 15:33:37 +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 BN2PEPF000055DF.mail.protection.outlook.com (10.167.245.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.0 via Frontend Transport; Tue, 5 Nov 2024 15:33:37 +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; Tue, 5 Nov 2024 09:33:34 -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 Subject: [PATCH v4 05/20] ACPI: platform_profile: Move sanity check out of the mutex Date: Tue, 5 Nov 2024 09:33:01 -0600 Message-ID: <20241105153316.378-6-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241105153316.378-1-mario.limonciello@amd.com> References: <20241105153316.378-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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000055DF:EE_|PH8PR12MB6795:EE_ X-MS-Office365-Filtering-Correlation-Id: c50279a0-0a90-4a09-8509-08dcfdaf3782 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?q?Rv50o/Po2SUD/JtmUeuYZ7CAfI5a73p?= =?utf-8?q?J+6BE8di8MYzToXeYcjVlm5qfXC8ZvPDWXhRw21WOQaGbl7Xi/yDqlsNxNct/ETXw?= =?utf-8?q?P5XMj5AP/B/XwS6EY3pQ/PgydKdF68uSpR8VMtZu7BZTJgymM1Mi8i375kjYu6+cS?= =?utf-8?q?4+BHXq2979iZ1yc9R9gxlAjs3qZZBlT+2LTfUYNK50MQCOXM3iJ6DInyR4E6RmNwe?= =?utf-8?q?QN8+jUzo8BinwhKl3eUELB018RSiOrcQ1j9F7REXoO+b05XBzlcziQL4fLqOpc+rD?= =?utf-8?q?32XtifP6GmzvadEW23JfTUMSCZB2aANmA1HQxGg0dYnlL78LTh4d5O6BCaKF6FRX2?= =?utf-8?q?4FGgEK96cF0Tl69C29o4EgAmXrEHp382nU8rcxR8QgL0VXCaKlQvsv80ukohnpbM+?= =?utf-8?q?YgdTEDS4cmTPwq2nCam77V5SUzJB9V78yR7E8bVA/hXEzKzK/HrJyT1C2CzPGeJ8d?= =?utf-8?q?qM8esRxt/aahda47JKNpjyRY2ioFpbOpo0rVVmawad85mV0jcZAbJpU2OcywmGeL7?= =?utf-8?q?b8p0ukBpPnjcSr7AsT3IUa7YCbaXByCsZkgVR4TkaQXoe7f9a4fqsRYDBmKQu9Jkl?= =?utf-8?q?5KpHvrHRRJ/bP1/YKhMWsvatLAO0aDDN+N4y+UjXFEQe+itB9BXQqA/rlTTkU/1Ep?= =?utf-8?q?NjYfrF2yori8e0W/+JUJXgCXHjepzWwl+ArDJCo5gvOP0lwrtl5OZ/lnkWGh4ILPw?= =?utf-8?q?nTAcL8gssDgmhwo4QIatQM7zxsZ4i1pIFpM7f5EuIzmCREq6kCiGdXu80LAq5jDJ+?= =?utf-8?q?pVMNxBNR0V5IFohOHi7O9cGEpcc1jRAVa/2pSvXTENZVd4Mh1LQrWAKapr/Kt1m/2?= =?utf-8?q?CXzU/A0usqHmNHlu4SEoeaojLNDYc0POsS34qs0A+q2coxGbdGmNKfMdNfbDLGbwA?= =?utf-8?q?T/6IZvNZh5qcDM6EdX3XNJ2PphqW3o7xnn2TIerJsWl/1n6lTtq1wE+SbIybQviBk?= =?utf-8?q?QsPiHpMkV2afIyBRh4T8cCd7jmH1m7MPro38FlLgiz9Bo29e8fQbvN6maVk1C1uuW?= =?utf-8?q?lzXIhmAOoeFCRDG27cfioa1EFn/o0qw4X10bGat7AtOFZu02KhV0eI0goANJmXYp4?= =?utf-8?q?/mShEq4HUtY9ciSrNY0s0PcNjXyZ8VYxkqKUAHQ86oI3FyXh8C70/6Vjf+Mtkge+J?= =?utf-8?q?JG3agfggii0atl35HBnU5984F6OhEXe9qnlMz/zkp4Hq94iHMAMVMyCRgP/KplVMz?= =?utf-8?q?ILMxrU5UYua6hOayoB0fpkITeBdmNTIxPyLNVhf8HlTNp4mAhMzpR4o3m+n0nqE7X?= =?utf-8?q?n0x/ORY+8ryTBfR5AFtVbS50gi1Udhuq6JONEswNvfDG2tce//XfbuMdrnLzphl9M?= =?utf-8?q?LlkA+owNpqM3k86yCGMbSi5n6pFYjhOKrg=3D=3D?= 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)(36860700013)(82310400026)(376014)(7416014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2024 15:33:37.1547 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c50279a0-0a90-4a09-8509-08dcfdaf3782 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: BN2PEPF000055DF.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB6795 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: Matthew Schwartz Reviewed-by: Ilpo Järvinen Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello Reviewed-by: Armin Wolf --- drivers/acpi/platform_profile.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index c76b8e3fdcde6..4e8a155589c21 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -179,6 +179,12 @@ 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; + } if (!pprof->dev) { pr_err("platform_profile: handler device is not set\n"); return -EINVAL; @@ -191,13 +197,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);