From nobody Sat Nov 23 23:39:27 2024 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2060.outbound.protection.outlook.com [40.107.95.60]) (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 53802146599; Sat, 9 Nov 2024 04:42:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731127354; cv=fail; b=XUuJx/walmlLl97XovPlVRskS67g9RGsUZBf+jIBE/Oz8KKGn99FV6JjyN5YqCIE+XIDRjMMWRIIfbQpL53hrzCoNDwnhHtuorCkGSndJ/OaIqbZHgu3oLc/eTBgO/WQtBZhXfrp1qALId9M1UJX4u+qNWxEw9hRWetJAtwA98o= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731127354; c=relaxed/simple; bh=qxZR0ioXhz7I9mrAT8p2DAj4zP/orxCZ1guCEIlDwcY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GSTsV94rXmO7iqJAXrtcD0a4gCdFxRU1Nb1gaNfIXaiNRISghYThNemstTCywv12Hchz6exk5toIiwon8xW+lNwCzZjHOv2W+wJatmBc8iG8vfJb05pSodFDViSwoIBuVMLHOWwRsdtuC4VH0nxoSkVpKU9jDkQiXX9MwElgbW0= 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=COY1Kx2t; arc=fail smtp.client-ip=40.107.95.60 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="COY1Kx2t" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=SlWCXY+RH7u32d0IGO/F6E6IqpCTRvqCnWX3mMztgEyE89c396Nq/SBaSUWYWAb0jKlCP3LiTM/xhfqKX5hCas1KtOFw3JpaiaKhe/o5c8+oxyon5Smf4CjMLCQEhXZPzIT5ABwEVfm7C2sy+MkfinJu/Zgnb7oBj7CzF/cO9Z62k0PRLxpdv6Ly5jPxB7Ve0xAX3xGWXAQISp/MAi8xExslPKVLWwAE8TJz7AsGYEuTsCNpqm8LQc31QgCwlXWcWiF/0VgK3YA7vU8eIQCmf+p+5gdEwVYebU6X0U2dGmGQnY1yhlRPM6DddAGu+5XAVONlKqf+x80/khZX7rn4IQ== 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=eb96Rfxdmtyo0JIpdtirBRC/6HMVRjTmHsGHHm4KVnY=; b=HSCBrXYmByMYaxv44Ge+K5uiA2OZTxLLggZ82lk/CR6cQFlM5JbWx71iFREU/Ovl//chIFXLPO3W3/1guSIR8Vtx91lyV7jiyNsz+cMjMFBJzLI42O/G2BmiOtZtZrrDEa8LRtT1oThcTotQW/jjMEVP2tMa2APj6jXoXe8xdnCuEgD+w89hDwS3vOLKpLYIHR29xdakjAB0z08lgxSjrn79NiVWNMjNvCuJyegW5QxwkUffwqOA6xU3lsl4FyGudTbZ8Fa2HRd/kNjN//8fMAO8JbQSObZEN9UJtjcTMM0laAHweDZBC8C2oETP0k2JSbbjsSKvXzsHFL/ur8sOXQ== 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=eb96Rfxdmtyo0JIpdtirBRC/6HMVRjTmHsGHHm4KVnY=; b=COY1Kx2th7qMioNVYodIB8AWqiSubSJipJpeisBY3q2JYEG7UPG75Wmjldmi44SJRnXFpxjY75sGGX8VFKkJDONzeNIobNP3mxRi3k8XWg8Rt+nlysnrYEOR/Xxyo/bmZfmXshG1GaugLbUTa1QjQMtb+bHAMxfTcBcBWvhcxMU= Received: from SA1PR05CA0021.namprd05.prod.outlook.com (2603:10b6:806:2d2::21) by BY1PR12MB8446.namprd12.prod.outlook.com (2603:10b6:a03:52d::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.20; Sat, 9 Nov 2024 04:42:27 +0000 Received: from SN1PEPF0002636C.namprd02.prod.outlook.com (2603:10b6:806:2d2:cafe::55) by SA1PR05CA0021.outlook.office365.com (2603:10b6:806:2d2::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.18 via Frontend Transport; Sat, 9 Nov 2024 04:42:27 +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 SN1PEPF0002636C.mail.protection.outlook.com (10.167.241.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Sat, 9 Nov 2024 04:42:27 +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; Fri, 8 Nov 2024 22:42:25 -0600 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=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=20Kleine-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 v6 06/22] ACPI: platform_profile: Move sanity check out of the mutex Date: Fri, 8 Nov 2024 22:41:35 -0600 Message-ID: <20241109044151.29804-7-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241109044151.29804-1-mario.limonciello@amd.com> References: <20241109044151.29804-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: SN1PEPF0002636C:EE_|BY1PR12MB8446:EE_ X-MS-Office365-Filtering-Correlation-Id: 9365be0c-e2fa-4cb1-428b-08dd0078e9df X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|376014|7416014|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?B?WFppb2RNUVQzaEhXdDU3aXpzbXlXNUl0NllQcCs2Skp6SXMxbyt1c2JPQVFS?= =?utf-8?B?SGkzTVFsZDQxSWE2YlZCeExVUFhzZkErVUN2UEY0YWt2K2d4ZUVsY1BJaHFU?= =?utf-8?B?dFhISVJtRjZZUWd5V1gwelhJN2tKb0FTWHlWenl5b3VZZVg0b1RHK3VvdVlo?= =?utf-8?B?OU03cDVCVXJMR3YrY0UyUmpZa1p1NHNwc0V2YlBDVXNXeFQrWXZSbG1JRFU3?= =?utf-8?B?UjkyN3NvczAwdTIwMmVYQ3JvYVA0QW5lUjFjcTdTVHQrK3NZSDc0K2tFMFF6?= =?utf-8?B?OENXZnJSRnFZNTljUncvUDhKY2s0NUJhUm1LbmhjekJyQzh4REVOVzFlNkUz?= =?utf-8?B?TElHN3dEaWxsTDVJcHJZKzdCZTNZdEEvdzVXVis3d1pXWC8zQVZYS1FyelNI?= =?utf-8?B?N0dHV2s1WGVZc0JpMGNUUCtXTFNvZDhqWFU4ZGV3NDFlWVEwU0dTMHowWVBG?= =?utf-8?B?Snh2MTJWYkV4c3lKbVBNVmE4UTJOUlZCODlZYjRsWnZQUjlRem5wa2NCbDhJ?= =?utf-8?B?S2VsQzhOU3dJSExQNTRJT1BhQjNHclRTejdvTzNWVkp0dVREUS9FdzdtQ0p3?= =?utf-8?B?MXordTIvdkx6S0g1RC91eS9DVmxxZnlybUZlTWFaOGJNdlQ1SWNzVDZ5VHRz?= =?utf-8?B?TlNhUlFScm11M2hZK2ptQzhlNWxPNHpNZnNleEdmRnBhTHE4cDBFMytZSmFk?= =?utf-8?B?ZTc1UytRV3VzYUZ6S1lBbVQ1NmE4YzZQaU5wR0hxSzN1Y1RzSE82YVV3Q2RN?= =?utf-8?B?REtQU3RuSTBDNG4xaGl5aTJ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ym1VclBwSkpQVTM4eVQ0eUgzTkZ4emlISjBhQVlLalNBd1ZpeHRw?= =?utf-8?B?eTN6SjNKSWZuVDl2amdlcGdEcjg2Ly9OY0JEN3gzWG0xWkgweDNxby9iTlRo?= =?utf-8?B?TlBrRXZ1OXNMVWdFRjVZcXZJdHNiT2pmMGpRbVExWHBYNEVDdEIxci91K1Qy?= =?utf-8?B?a09oaVkyTXYwRWZrZVVuS3dkTno1c28xNHpPWVBTcnpqSEE9PQ==?= 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)(1800799024)(376014)(7416014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2024 04:42:27.5495 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9365be0c-e2fa-4cb1-428b-08dd0078e9df 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: SN1PEPF0002636C.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR12MB8446 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=C3=A4rvinen Reviewed-by: Mark Pearson Reviewed-by: Armin Wolf Signed-off-by: Mario Limonciello --- v5: * Add tag --- 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_profil= e.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; =20 + /* 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; } =20 - /* 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 =3D sysfs_create_group(acpi_kobj, &platform_profile_group); if (err) { mutex_unlock(&profile_lock); --=20 2.43.0