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 DDF27374CC; Wed, 7 Aug 2024 15:12:49 +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=1723043570; cv=none; b=JevqxVtq8CdRBI91uGKbHjv2RdCILjtV7v1E9vy+Evczak9MvaUzbBpfFOkblz2lGGJQoDwOLU+n9KRVREMVz4GUCMeSaAw1V4gsfS4abOkARZjfdjxjWl3c2GmruMvdbkYQ1RAyWIwH2LKgYpzrKj4pii0D93CibTPjRwl8K5I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723043570; c=relaxed/simple; bh=0KSWfif96MaBeF0f/3rChJ25QB3nLeRelYdvbCvIsRc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Pa3PFlZNe8/EjhiPYUxandU2bdv/Ths9ko02ad+C+K0Bf5gciUNJEKZCCzo1b6VMm2lgOYxLEIgwmq6CWF/0MGNwKsFvNBJCZzMtFPOwgXlA+Gq5Y6sqTfyegPNK6oc+A0Ibef2/lvHVdDCZUvqRSEqMyJ1ec7Z4gIkJ5pm2xT4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=C7oVKPe4; 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="C7oVKPe4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 68F94C32781; Wed, 7 Aug 2024 15:12:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1723043569; bh=0KSWfif96MaBeF0f/3rChJ25QB3nLeRelYdvbCvIsRc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C7oVKPe42l5QvrxvYmvExaRv8pO3arWbhihmPz/JK/CscczP3eroVw7Lruj3oeBim h2X7bPE4yl7mOyChtroWFXUoVrA05lkVOOEhpywTlAE0yFLJo2ovLMGBOCX1TZlMU4 CHmYLIdlpE4JOW3s7Z4/5/M+KMIP6SkZeITYpYPs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, "Dustin L. Howett" , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , Lee Jones , Sasha Levin Subject: [PATCH 6.1 19/86] leds: triggers: Flush pending brightness before activating trigger Date: Wed, 7 Aug 2024 16:59:58 +0200 Message-ID: <20240807150039.874827418@linuxfoundation.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240807150039.247123516@linuxfoundation.org> References: <20240807150039.247123516@linuxfoundation.org> User-Agent: quilt/0.67 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-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Thomas Weißschuh [ Upstream commit ab477b766edd3bfb6321a6e3df4c790612613fae ] The race fixed in timer_trig_activate() between a blocking set_brightness() call and trigger->activate() can affect any trigger. So move the call to flush_work() into led_trigger_set() where it can avoid the race for all triggers. Fixes: 0db37915d912 ("leds: avoid races with workqueue") Fixes: 8c0f693c6eff ("leds: avoid flush_work in atomic context") Cc: stable@vger.kernel.org Tested-by: Dustin L. Howett Signed-off-by: Thomas Weißschuh Link: https://lore.kernel.org/r/20240613-led-trigger-flush-v2-1-f4f970799d77@weissschuh.net Signed-off-by: Lee Jones Signed-off-by: Sasha Levin --- drivers/leds/led-triggers.c | 6 ++++++ drivers/leds/trigger/ledtrig-timer.c | 5 ----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c index fe7fb2e7149c5..3d3673c197e38 100644 --- a/drivers/leds/led-triggers.c +++ b/drivers/leds/led-triggers.c @@ -200,6 +200,12 @@ int led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig) */ synchronize_rcu(); + /* + * If "set brightness to 0" is pending in workqueue, + * we don't want that to be reordered after ->activate() + */ + flush_work(&led_cdev->set_brightness_work); + ret = 0; if (trig->activate) ret = trig->activate(led_cdev); diff --git a/drivers/leds/trigger/ledtrig-timer.c b/drivers/leds/trigger/ledtrig-timer.c index b4688d1d9d2b2..1d213c999d40a 100644 --- a/drivers/leds/trigger/ledtrig-timer.c +++ b/drivers/leds/trigger/ledtrig-timer.c @@ -110,11 +110,6 @@ static int timer_trig_activate(struct led_classdev *led_cdev) led_cdev->flags &= ~LED_INIT_DEFAULT_TRIGGER; } - /* - * If "set brightness to 0" is pending in workqueue, we don't - * want that to be reordered after blink_set() - */ - flush_work(&led_cdev->set_brightness_work); led_blink_set(led_cdev, &led_cdev->blink_delay_on, &led_cdev->blink_delay_off); -- 2.43.0