From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796388556; b=1BoGTO3OF3ab3538aTqqmwf4q9zhCKDMRiGDUaQrJT/OIcadALXuwTKmQOazUsWnfsxy MEwY67IxrjGoBDd2SevSEqUC0ELDA4W1mU/kNhXPcRpOAI2nzC5EDb9Nz74HVTcb/MA0I RwnKZhSq2cXCMAhEzwEcUaaJCAvhZKmKdYR18Y4zzc0yY34AwUcLaj044phvjDrkni8Ao MzVhr/DjgMkSkF6oxkvU57YJSzJKmcxIfT/CijWDXXzIA3dX6jxBSWe88UA26Kq3ro2VO wcxP4/DCZglC9KgNEEBq5MtulkhT2m4KcS50VFQ6kMVkd6UZ0V8/zX74ikx6URxQo7w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796388556; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=HdG7ayM+3mM/oL/c39YbgH8mB9Q/oKxMJP4SArqb+Iw=; b=opS1c0DkpeFlT7OJKfvdRWYkCoOO/XYTWURn7zePRgzClEwRYCSoXPMtnQYmiH3r5VnB +0mV2DF6WLNnNIvgWeKI4dTluTxut0vptnpjdfa3mjGCX1cB73lHlX+YlxdlS8cixt6pc nAIrYKSEBnGHQ4ia8F7AGOMGLSlrlx4dHHdg0Q8Yb3WZhfCSeEOoGXWxdt/c2UJjXg4aM SXRdllyxuAgfJ+lnN9qFPw2+CTt53CiW3jk1IXRscCfmIO84wgBSAr0wzxAFwgpVYUA6n dKPefuyKm+tv+VAbJFop277c41dOJBJMJjVqsg+paaWc2Ot32sT1j++ZYgeAriGL4ag== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=RVLnbNOg; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DA51A606A322; Fri, 4 Dec 2026 12:49:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=RVLnbNOg Received: by smtp.kernel.org (Postfix) with ESMTPSA id 509F41F000C2; Fri, 4 Dec 2026 12:49:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796388556; bh=HdG7ayM+3mM/oL/c39YbgH8mB9Q/oKxMJP4SArqb+Iw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=RVLnbNOgzfKORlF9RZQh07A5lj+8iRtKf6KSLoJPjaIoGY28/v2vEO1NjB/WTVj/H byjgVHlk7oSS3pgOQE4P/DmHPyJ/11uZoU59ko1rdu0U4fQVhnwEv4Y2gP/Tgk5w/h 0WkfDI3QcSqC6Zqfrp5UUmA+Iqh8FMa7ye9hxurU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Guangshuo Li , Joshua Crofts , Jonathan Cameron Subject: [PATCH 6.1 0627/1059] iio: accel: kxsd9: Fix potential use-after-free on removal Date: Fri, 4 Dec 2026 19:02:38 +0900 Message-ID: <20261204100700.337719669@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Guangshuo Li commit fd7334314f63a3a2a4927f209b2ca0e33d111840 upstream. Unregistering an IIO device with an active triggered buffer detaches its poll function. Freeing the poll function first can therefore make iio_device_unregister() access freed memory. Unregister the device before cleaning up the triggered buffer. This issue was found by our static analysis tool under development. Fixes: 0427a106a98a ("iio: accel: kxsd9: Add triggered buffer handling") Signed-off-by: Guangshuo Li Reviewed-by: Joshua Crofts Cc: stable@vger.kernel.org Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/iio/accel/kxsd9.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/iio/accel/kxsd9.c +++ b/drivers/iio/accel/kxsd9.c @@ -484,8 +484,8 @@ void kxsd9_common_remove(struct device * struct iio_dev *indio_dev = dev_get_drvdata(dev); struct kxsd9_state *st = iio_priv(indio_dev); - iio_triggered_buffer_cleanup(indio_dev); iio_device_unregister(indio_dev); + iio_triggered_buffer_cleanup(indio_dev); pm_runtime_get_sync(dev); pm_runtime_put_noidle(dev); pm_runtime_disable(dev);