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=1796381022; b=UuA1lgb7RGTKFYhKj+NePwl6pwopSxc8vr6USF7vg9bpbRu8g555H+7M9eBckeewymx3 pusPBVV4svn5nVIhErkU0UvDhDbZBhgdDBsbJfFjZ2NDEvIvwTetCzbyzzcSjC6e8afyv 4uMUofQ6Oq5lC74TNhpJzdGbxh/LjXx2ROwFKYwo+4fT1As7+gNQ4powsr2MKe7q/V+O4 eD5FzoJF+J1CsX6uNHiUErHgv1axyTeszjTCcNmClsV8UzkwSJalwmOwUtfNVF/HiIPpl pYt6Z78bCeyfJqsWAI5I3an9v3wj6w5UGIyHO+Uo6V9UGwTmeXwZl3jae1PSrmZbNvw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796381022; 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=krSVscn1pJU6T0V8hMZrd7nb0cBJM6e3bIe6QvCrnIo=; b=wNnmmvPDRebKO9GnVCsriva6FDk55uIwX+JJgqoIgCdlXISmAhPg/brkUHJlecxnHvru B2eiWAhuaf3fSZ54urvYgsCyLkoO65+aDUrTG2eM6CN/lhcMPfVVypH+RYi4nIHqzT5Ce 3RjG/TFsGwTSZTWZfVfzIMf+hlxZydpqImX62CcIMC0VpoEDj90t5LO4NdKKC3eaIoK3d L7xF3uEVLLOs6HWCplVyXZ4qVcSbhUv5/h8rPLcwNXzhG2CmmQqBnBKeHRy3mfXLeH66m OgsUA8sPPiMJW9P+yacXbnXGVSXKK4PCoAEzfijqs3taJG5UEtgRHn3czw1Lcx9RqVg== 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="WQoAUv6/"; 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 78078606A322; Fri, 4 Dec 2026 10:43:42 +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=WQoAUv6/ Received: by smtp.kernel.org (Postfix) with ESMTPSA id DF8301F0092C; Fri, 4 Dec 2026 10:43:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796381022; bh=krSVscn1pJU6T0V8hMZrd7nb0cBJM6e3bIe6QvCrnIo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=WQoAUv6/EjvH9RurWdxlbTntfIBr+FlVhz+GA1L95bELqGMuK7Hk2v+Oj6JBIK4Oo qcgqT3lfM4n/88MULt0+uF3tSESzBfV0CkQUDMsoLFci5eyNhhFYi3DYlO2WeFKiWG d+IH+HTDR603nDZOwlfVCqkO9V/Ui62p5ph59N6I= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Kent Gibson , Bartosz Golaszewski Subject: [PATCH 7.3 487/742] gpiolib: dont overwrite the entire flags field in gpiod_get_direction() Date: Fri, 4 Dec 2026 19:05:51 +0900 Message-ID: <20261204100648.072975823@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Bartosz Golaszewski commit 8ed87a9adf48703b5729f9d020eb15fa79ffb099 upstream. gpiod_get_direction() snapshots desc->flags with READ_ONCE(), updates FLAG_IS_OUT in the local copy and writes the whole word back with WRITE_ONCE(). Any bit that a concurrent user sets or clears atomically in between - for instance: FLAG_USED_AS_IRQ from gpiochip_lock_as_irq() - is silently lost. Update FLAG_IS_OUT with a single atomic assign_bit() directly on desc->flags. The earlier READ_ONCE() snapshot is only used for the open-drain check and stays. Cc: stable@vger.kernel.org Fixes: 2559f2e09211 ("gpio: reinforce desc->flags handling") Reviewed-by: Kent Gibson Link: https://patch.msgid.link/20261110-gpio-desc-flags-atomic-v3-1-2f463bce8086@oss.qualcomm.com Signed-off-by: Bartosz Golaszewski Signed-off-by: Greg Kroah-Hartman --- drivers/gpio/gpiolib.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -490,8 +490,7 @@ int gpiod_get_direction(struct gpio_desc if (ret > 0) ret = 1; - assign_bit(GPIOD_FLAG_IS_OUT, &flags, !ret); - WRITE_ONCE(desc->flags, flags); + assign_bit(GPIOD_FLAG_IS_OUT, &desc->flags, !ret); return ret; }