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 732FC1B81DC; Mon, 2 Jun 2025 14:32:34 +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=1748874754; cv=none; b=N2rcCEH/FqbCyKhz9aKFwi+ZXx7cLcWDYjqy6Hlvo7NWrUYDo8sik85yy5xZ63PXzlV8YEYBSbzh4bxWG3hI4ep2Ubx/Ne5Xqrb0Gmxl4+teJB1b7M1fhTG1jhFBZUSRUrOWFtYU3mXVwELMYSWgSHG33aEK/1jDnvlh0vWGfXQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748874754; c=relaxed/simple; bh=dfRMF3keOXcpR5W5N6TVTP1vf4M1xt6rsy1EyAt0vdk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ttJLV7gwc3GXrYZsWrpxkjJa8XO9uTYZ3CVZAP1GSHsv2emWSjJwgruLvsex6i7yhK1nurC1WvQHaT1M+fLfJBvJAzbwOck0NnsjcXkfSUuJ38PP68G0ixeGdEku1kXJWDwZzruyyH/xJTrNsohoYw06i7mKozHrg2u+weYOO30= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=WypBuZcX; 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="WypBuZcX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84467C4CEEB; Mon, 2 Jun 2025 14:32:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1748874754; bh=dfRMF3keOXcpR5W5N6TVTP1vf4M1xt6rsy1EyAt0vdk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WypBuZcXVHb0yeiurZDp0jtrZTgvQZdJVWGnsqIOXPMy0WSjpn2tfnkRvZsaGz9xh i0Le+p6Sl9vJNJWIOiJMonqDACo9luMkxclhVpHgrncBlqBJGuNpDY0V1WO3S0I17Z 6rGk5N4q7DlSbEEYF8SmgZJws9V/A4ue341a1zwc= 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.4 125/204] hwmon: (gpio-fan) Add missing mutex locks Date: Mon, 2 Jun 2025 15:47:38 +0200 Message-ID: <20250602134300.557469219@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250602134255.449974357@linuxfoundation.org> References: <20250602134255.449974357@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.4-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 d96e435cc42b1..e0b3917dfe6f9 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