From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 17BF5225419; Mon, 2 Jun 2025 14:55:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748876130; cv=none; b=a6KO/VtLqhaP0rsllATEGFrdWAVLFPDCUNfa91MyLqHwYj3HnKCqEa/qVbLjBvxtvBcuPunqFA4zc9Mf8yT87Cc36aKPSWfS48f8nSSI00T/vTCjExBu916PzO6PVyFxrYRmKeiVWuo6mfrBTjgvC3+vdSqD75f9HE/nJOjbSdE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748876130; c=relaxed/simple; bh=CUlGW1u/v/vK32oVGKTRptyg0peRmjQNPF6eC3O92KQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iSYll4Q0jHqJJD54l0ToBSTy+dVwQqViVRHqnlna9VGDo/p/gvA9xctScaPlzZ5SBCitVSeWT8ZOAF7mNEH8hb8hC+SNNsBmD5hvxAfkr29TXAfcWTu1F8WKvavAizvYZYon50NsaqCtg6xOV4WLTnVxYh++UlWq7IVBJNPUPBw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=1kCo0bJl; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="1kCo0bJl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7C76FC4CEEB; Mon, 2 Jun 2025 14:55:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1748876130; bh=CUlGW1u/v/vK32oVGKTRptyg0peRmjQNPF6eC3O92KQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1kCo0bJlQIIJv8Ghu/Q4cUtuFmq5A9R6Sqp8LKr+NFCca9I1nYC7KFJHh3XVbSZoh MJ4F+JahW2KXWRw3iHqxwvmSaAnjMfcQjiBKqWxKQu09ZoMVQBwayVjUrGctLPLxd3 2BakGMlINoJ46P25L+mP9+Z4HMSmAawrw+awKVOw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Alexander Stein , Guenter Roeck , Sasha Levin Subject: [PATCH 5.15 080/207] hwmon: (gpio-fan) Add missing mutex locks Date: Mon, 2 Jun 2025 15:47:32 +0200 Message-ID: <20250602134301.867326433@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250602134258.769974467@linuxfoundation.org> References: <20250602134258.769974467@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alexander Stein [ Upstream commit 9fee7d19bab635f89223cc40dfd2c8797fdc4988 ] set_fan_speed() is expected to be called with fan_data->lock being locked. Add locking for proper synchronization. Signed-off-by: Alexander Stein Link: https://lore.kernel.org/r/20250210145934.761280-3-alexander.stein@ew.tq-group.com Signed-off-by: Guenter Roeck Signed-off-by: Sasha Levin --- drivers/hwmon/gpio-fan.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/hwmon/gpio-fan.c b/drivers/hwmon/gpio-fan.c index fbf3f5a4ecb67..6d518c10723a0 100644 --- a/drivers/hwmon/gpio-fan.c +++ b/drivers/hwmon/gpio-fan.c @@ -394,7 +394,12 @@ static int gpio_fan_set_cur_state(struct thermal_cooling_device *cdev, if (state >= fan_data->num_speed) return -EINVAL; + mutex_lock(&fan_data->lock); + set_fan_speed(fan_data, state); + + mutex_unlock(&fan_data->lock); + return 0; } @@ -490,7 +495,11 @@ MODULE_DEVICE_TABLE(of, of_gpio_fan_match); static void gpio_fan_stop(void *data) { + struct gpio_fan_data *fan_data = data; + + mutex_lock(&fan_data->lock); set_fan_speed(data, 0); + mutex_unlock(&fan_data->lock); } static int gpio_fan_probe(struct platform_device *pdev) @@ -564,7 +573,9 @@ static int gpio_fan_suspend(struct device *dev) if (fan_data->gpios) { fan_data->resume_speed = fan_data->speed_index; + mutex_lock(&fan_data->lock); set_fan_speed(fan_data, 0); + mutex_unlock(&fan_data->lock); } return 0; @@ -574,8 +585,11 @@ static int gpio_fan_resume(struct device *dev) { struct gpio_fan_data *fan_data = dev_get_drvdata(dev); - if (fan_data->gpios) + if (fan_data->gpios) { + mutex_lock(&fan_data->lock); set_fan_speed(fan_data, fan_data->resume_speed); + mutex_unlock(&fan_data->lock); + } return 0; } -- 2.39.5