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=1796385857; b=2EcG00ZNFQlByn77y6FogIcxDcCNvRakDeyTQkVrghMHlQ7V8VAwpcD2zb5/GFhaRMtZ 9x/J/1albvMFbosa3kiKsdD/3x0+STwECF9lLaQ/Qq1ksGzdNCPIQJaGuNwirjOSCZlEw NkmyEzxRgngLPa7dJ3MfCqBSMUF/vBzFAHYH8LKwy9WUZFzidXzHJ1LfSKVeQFmCq6eGP OhV6e70v/+zWCneTsAWVf9yUcBmqAY+G5Bb9n2i5wKCjWFtPHIMfg326bAck36ouCrH0i yTohyzN4KQnSRMBYljUK+k63Ea5EX0SSZ+VuWcnBwZFci6/S0nQnT8rRmZqRFyWW3uQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796385857; 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=Mwo8QJdRZt86fuIPlABD1r/+NI5zZFIuOIbvnZLKgwY=; b=OXj1111q8YUtnBTIuq8HTFGQEMe2Gwtcukweo54CNH0one2+CFoZ/C9WrMmfwC1BsVY3 TruWK0TJ/UqQUodNSshHMiQMYHQ6cIf1hkYD146ApsTOOEIq+UvuubmSAHbTLovoMJ2rZ upla4EBNqdwFq8vIa6nkfFsupuA6WNxuRdf11j/5h3lrNk/3fNP+VuvEkHV7JCOOnaE0d C6NUfnpx6awdBKokfAZujCiUTYpCua1QPHVjXGcBMCncaP4f2UJbEyX9+7/yR2R1q5VpJ uBrPxVPoyVnMv/i1kPQd/qXWjkYm0z/U6B+jSJSf+zqKHlI7kI4SDjDQidO6AETJQaw== 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=XoLQwAAJ; 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 A28E5606A32C; Fri, 4 Dec 2026 12:04:17 +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=XoLQwAAJ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1E7BE1F000C2; Fri, 4 Dec 2026 12:04:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796385857; bh=Mwo8QJdRZt86fuIPlABD1r/+NI5zZFIuOIbvnZLKgwY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=XoLQwAAJEglCucVrXERwm+VledN0qw0cylkV6HEcV7dWouhqkYx3bm9v8FsFmlQDy qv1rsJEnysGCvSKJCIhASf+yCir9DCEEKTz9920NPV436LyYhXjmA4HvOOxegE8D/s 2hre8oJIa4moMu0k+wXzUgzy3V+n4xwi60cgOy+U= 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.6 0680/1167] iio: accel: kxsd9: Fix potential use-after-free on removal Date: Fri, 4 Dec 2026 19:01:47 +0900 Message-ID: <20261204100719.769143546@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@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.6-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);