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 EF7758BE8; Tue, 30 Jul 2024 16:34:02 +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=1722357243; cv=none; b=NTrv5mcIHCJ8G8rzgVO1FoU+Sk1v+pb0pjPDbmcn378ZsdBjWWLhcjWN1T2ZSrS8lO7rt/xmZtkOWVdnnjsOMMbS/tzlEVTF9MEn9mMC52NZ6zyoibnttvIbHRLXcg+qh54v4RjQXF9YPBDYd5y75gy6l0de2o4eKo00Sct62FI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722357243; c=relaxed/simple; bh=oa126hL3r8QGelcOglTNlr3575YiXOWqcUHtQg3DTF0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=oAqhl+baOaI5M+I76gR12o9qIx7cfmgVeMlD6vBf/2VSwEdoTFjh/lBbHAvci99U1krCgkLCf6t5wzZJNfaRgcJvl77+6QMQRihQMgrGbrITuKXC5mzvANxtTfxenVI0OUqiJCsy5BNbTDmZk/FkLC7gwwK9OgL+82p1tbHbaaY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=AlDvxB2x; 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="AlDvxB2x" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5EA7FC32782; Tue, 30 Jul 2024 16:34:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1722357242; bh=oa126hL3r8QGelcOglTNlr3575YiXOWqcUHtQg3DTF0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AlDvxB2x+ZaIgFEndS1zArc6ZtL9FXg0laMDoRPl51IBGKoeQjDX0gRn15ZbrVKdO 2qPjLmlSFAHjBP1eDxuTT5h+jbaurl82D2MX0o7ZjtjYr0ybGtKdle2ilRdjr6VJqZ xN2lGtCzbxaRObEdRJtg22y3HWewXB68xaSbB//k= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Hans de Goede , Lee Jones , Sasha Levin Subject: [PATCH 6.6 221/568] leds: trigger: Unregister sysfs attributes before calling deactivate() Date: Tue, 30 Jul 2024 17:45:28 +0200 Message-ID: <20240730151648.520468839@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240730151639.792277039@linuxfoundation.org> References: <20240730151639.792277039@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: Hans de Goede [ Upstream commit c0dc9adf9474ecb7106e60e5472577375aedaed3 ] Triggers which have trigger specific sysfs attributes typically store related data in trigger-data allocated by the activate() callback and freed by the deactivate() callback. Calling device_remove_groups() after calling deactivate() leaves a window where the sysfs attributes show/store functions could be called after deactivation and then operate on the just freed trigger-data. Move the device_remove_groups() call to before deactivate() to close this race window. This also makes the deactivation path properly do things in reverse order of the activation path which calls the activate() callback before calling device_add_groups(). Fixes: a7e7a3156300 ("leds: triggers: add device attribute support") Cc: Uwe Kleine-König Signed-off-by: Hans de Goede Acked-by: Uwe Kleine-König Link: https://lore.kernel.org/r/20240504162533.76780-1-hdegoede@redhat.com Signed-off-by: Lee Jones Signed-off-by: Sasha Levin --- drivers/leds/led-triggers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c index 6a5e1f41f9a45..4f5829b726a75 100644 --- a/drivers/leds/led-triggers.c +++ b/drivers/leds/led-triggers.c @@ -179,9 +179,9 @@ int led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig) cancel_work_sync(&led_cdev->set_brightness_work); led_stop_software_blink(led_cdev); + device_remove_groups(led_cdev->dev, led_cdev->trigger->groups); if (led_cdev->trigger->deactivate) led_cdev->trigger->deactivate(led_cdev); - device_remove_groups(led_cdev->dev, led_cdev->trigger->groups); led_cdev->trigger = NULL; led_cdev->trigger_data = NULL; led_cdev->activated = false; -- 2.43.0