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 C4FAB27448; Wed, 7 Aug 2024 15:09:01 +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=1723043341; cv=none; b=tRXU3xf+9DcG2h4xgYDyHYz90zVG4o0wzkDI0OfdPfKWYsCkVOyfijd1r5ua91toEZOLR/OE4iA4Yt4auuUt1gE7lrzN0+YD3h32n+eYlvOhbJyQOeM0FeUrrWddLsb2WFyMYfigs0zmPYLnd9nvnZLGPvhRqbJI5nDq3NmMhjg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723043341; c=relaxed/simple; bh=aN5NKphGwea0f774GGKh8HjsBQTPquQAprJhF1XbzgE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YyTBy6bul1qh3xkX+FJqe5rPN+2xFZfpxWFA2rRTUz19jQs+SIBBa7cPLsErorXyy6bZojTJ4/BnqiNujFJM9PWrKanaJ3awUyqHvvaXJZDSRx/yBI5Ob9BHDM0O7eQbBl64CXDAjOLzimIuQs/yyec7xf/Bv1yETdE605qhYjc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=IL/gCpRS; 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="IL/gCpRS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4F5CFC4AF0D; Wed, 7 Aug 2024 15:09:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1723043341; bh=aN5NKphGwea0f774GGKh8HjsBQTPquQAprJhF1XbzgE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IL/gCpRSxLWY5SGgkTClXMESoKsw80NH3PieZVT5UZ0//4Y1UR0ETAwC8G3kQDBvJ PoARxz8NsSY2La7tYDVurp9FBQkJ4OU9KdT8zUEmUG6z0VXqVLDgKvdo2aDhu9Lyma rRBvsPRcFOCro2dPidGKCFBb+vysHrY96rBVCLZY= 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.6 026/121] leds: triggers: Flush pending brightness before activating trigger Date: Wed, 7 Aug 2024 16:59:18 +0200 Message-ID: <20240807150020.200342432@linuxfoundation.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240807150019.412911622@linuxfoundation.org> References: <20240807150019.412911622@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.6-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 baa5365c26047..72fd2fe8f6fe8 100644 --- a/drivers/leds/led-triggers.c +++ b/drivers/leds/led-triggers.c @@ -201,6 +201,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