From patchwork Mon Jan 30 18:47:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 50425 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2347699wrn; Mon, 30 Jan 2023 11:07:33 -0800 (PST) X-Google-Smtp-Source: AK7set+BJ3cWciB3wLuflsIDPjqZl3JKqsrJmvVYWXz2IRlhlkXcg/ZxRVn1chMpELqRJATmGqco X-Received: by 2002:a17:907:da1:b0:888:7ce4:1dc1 with SMTP id go33-20020a1709070da100b008887ce41dc1mr6842424ejc.26.1675105653595; Mon, 30 Jan 2023 11:07:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675105653; cv=none; d=google.com; s=arc-20160816; b=KFQl2JxPpxSNIrbMyxPmLCQyxxTVtjjvq1NDhbMof/E3mMhVGPUr7F2xsoWrobiM/T uI5JY94oRRIXSWF7+1fZ1nX9LQn0SjRL8yY6ezzA+rv8p6pXnh4OALHuy2x/fVvzVqKx T24NJqjxAHlZg+qVeTKSfFxt9fjSON2q7yG5zqWB4GljWLScosij9FH8hI3UZShVjukk 7y4QS06SbF65pqmENUvOg5+CkCgXppRfxZt6b5r+PUTnXm0JwaLl3WEtorFeQA5Nfoux fe8pTMsOYxWMRKmCiCtOq0aImWhKqTVQlHUVdViznjWXxC892S2xMw5StKEiSvMRVoz3 LrgQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=W1Gd1Icwci5AFUxcseLITko9Dg2yFl6yP/HgissYkcU=; b=maGlukLPLJLpfAs6lP2SjgNBwNAD1P1T3G4seiDtX0VXwSBjSpHfLaBfZH6X6pF3ip AkYkjDl0Dp+BtzRdYMI3Wj+4AypUKh/JAS0zPccqid9iOImthJ7yNEByVfeaZ59jJN4B TLe+njJhC13Gi2ZZElTG5NShqGpX2N3Gq1sacu6dIceLmhPPoPHAohjCLQ4eVLx5fLZm tsdB6BiowPB/IRseWfQh3khOUJFg7qlB9HcD6ggz13Vs7V5+DGN4EzkvEIg2HBvo0bbM RTBpwdoCwUNuYmhzTetSUDJc4PEtxF3iI7p/QQujXVofeHaF2nBpR/fxSZ4AylBNWK96 i8Rw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cm17-20020a170907939100b0088b553a6261si916192ejc.868.2023.01.30.11.07.09; Mon, 30 Jan 2023 11:07:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236753AbjA3SsF (ORCPT + 99 others); Mon, 30 Jan 2023 13:48:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236090AbjA3SsD (ORCPT ); Mon, 30 Jan 2023 13:48:03 -0500 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 309961421D; Mon, 30 Jan 2023 10:47:56 -0800 (PST) Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 5.1.0) id 8426bca2ecd88b5b; Mon, 30 Jan 2023 19:47:55 +0100 Received: from kreacher.localnet (unknown [213.134.169.112]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by v370.home.net.pl (Postfix) with ESMTPSA id 1C48725258B8; Mon, 30 Jan 2023 19:47:54 +0100 (CET) From: "Rafael J. Wysocki" To: Linux PM Cc: Linux ACPI , LKML , Srinivas Pandruvada , Zhang Rui , Daniel Lezcano Subject: [PATCH v2 4/4] thermal: intel: int340x: Improve int340x_thermal_set_trip_temp() Date: Mon, 30 Jan 2023 19:47:43 +0100 Message-ID: <3719164.kQq0lBPeGt@kreacher> In-Reply-To: <2133431.irdbgypaU6@kreacher> References: <2133431.irdbgypaU6@kreacher> MIME-Version: 1.0 X-CLIENT-IP: 213.134.169.112 X-CLIENT-HOSTNAME: 213.134.169.112 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvhedrudefvddguddulecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpedvffeuiedtgfdvtddugeeujedtffetteegfeekffdvfedttddtuefhgeefvdejhfenucfkphepvddufedrudefgedrudeiledrudduvdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpedvudefrddufeegrdduieelrdduuddvpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeeipdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqrggtphhisehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepshhrihhnihhvrghsrdhprghnughruhhvrggurgeslhhinhhu gidrihhnthgvlhdrtghomhdprhgtphhtthhopehruhhirdiihhgrnhhgsehinhhtvghlrdgtohhmpdhrtghpthhtohepuggrnhhivghlrdhlvgiitggrnhhosehlihhnrghrohdrohhrgh X-DCC--Metrics: v370.home.net.pl 1024; Body=6 Fuz1=6 Fuz2=6 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756475585503047297?= X-GMAIL-MSGID: =?utf-8?q?1756475585503047297?= From: Rafael J. Wysocki Instead of using snprintf() to populate the ACPI object name in int340x_thermal_set_trip_temp(), use an appropriate initializer and make the function fail if its trip argument is greater than 9, because ACPI object names can only be 4 characters long and it does not make sense to even try to evaluate objects with longer names (that argument is guaranteed to be non-negative, because it comes from the thermal code that will not pass negative trip numbers to zone callbacks). Signed-off-by: Rafael J. Wysocki Acked-by: Daniel Lezcano --- v1 -> v2: New patch in v2 --- drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) Index: linux-pm/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c =================================================================== --- linux-pm.orig/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c +++ linux-pm/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c @@ -42,10 +42,12 @@ static int int340x_thermal_set_trip_temp int trip, int temp) { struct int34x_thermal_zone *d = zone->devdata; + char name[] = {'P', 'A', 'T', '0' + trip, '\0'}; acpi_status status; - char name[10]; - snprintf(name, sizeof(name), "PAT%d", trip); + if (trip > 9) + return -EINVAL; + status = acpi_execute_simple_method(d->adev->handle, name, millicelsius_to_deci_kelvin(temp)); if (ACPI_FAILURE(status))