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=1796384214; b=vrL0Y0wQA5ymXnIk87EU8QQBW43wiq+qvazpdAmGoHWrYF5Zm8g0CZPux235o0DZzWWy AMrCSLVwGgUy3T18NQAnBCyjCVCKHvWgklIpdgioC92OEb2eBB6Gm/5FIDp136jJ1PBYc AaIr3C+yBVPMIDODc8cRy3AL3cMG3Ibk5yUZuWhtUKTJz7VJYUUtH2UJXyXXwZ8AkcCe7 gE6+sRKB8mHWYcTEqQc2n2Lb2Y88QQ50UpyYHTT+WTHSS5ps7Mnl3AzHw1FFaOuC1X5n3 HFrUilYhy/fJwjn0adm+x88WsmYFojHF8OyfTXdN4kNZ2mZB6BXvYA8AhZHIbyCBZfA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384214; 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=1Qlg1ifbVirv25S/CYYeutmoub3BlOwHLZN/wNXZ2nY=; b=XaJiNI9ypAR64XkfnVri07VaFQJTKZm6zumVdudpmmJWSQr76LrAsfrliw/W7JLPxzpg eHF0uOdZBUadpZ0qXN1s4vnjIkGVsbOfLubzpaRcPGEtEs1sZGO2/IW6VpPfKEO1l2ZNl ZIP4m/JunLtxL1q0DhkiliR9AprTrjyzPh7Cohd6OIsGNnJOWoxLHFvAdYcCcrM2fyPqq quxS6VHKTheoOrR+BeYAlBNmPKLa0mJ7PWqki2xlX/hZ36q924Cb2uNG6X5Y+vzgVSgAb sX99ovSGt2UqG52Jn3Y0awZv5padmw4MsjEtjX6KnOcnZmJJyLb2ym45qsBx5ABL5GQ== 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=I4NrIG1h; 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 DD5A5606A322; Fri, 4 Dec 2026 11:36:54 +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=I4NrIG1h Received: by smtp.kernel.org (Postfix) with ESMTPSA id 553D71F000C2; Fri, 4 Dec 2026 11:36:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384214; bh=1Qlg1ifbVirv25S/CYYeutmoub3BlOwHLZN/wNXZ2nY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=I4NrIG1hHO37RhyNfGOdJuA1msr89NTBcDE6WBLrV+3laGT3K7E1UMizNKCJc4QVe YkZ2rUz2Wn0rSOmsgTQxw4GpMtFshmEknKpnOsbHk245ll34Du3bflUmZcl5/cEgmY vgRBI1VwUMBKEoigXcwb2zREobKQ2e9shnBHRpUA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Kent Gibson , Bartosz Golaszewski , Sasha Levin Subject: [PATCH 6.12 543/555] gpiolib: dont overwrite the entire flags field in gpiod_get_direction() Date: Fri, 4 Dec 2026 19:09:46 +0900 Message-ID: <20261204100629.305636142@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@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 6.12-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: Kent Gibson Signed-off-by: Sasha Levin --- drivers/gpio/gpiolib.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index b3a557c41fa91..2fcf98ffc1932 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -393,8 +393,7 @@ int gpiod_get_direction(struct gpio_desc *desc) if (ret > 0) ret = 1; - assign_bit(FLAG_IS_OUT, &flags, !ret); - WRITE_ONCE(desc->flags, flags); + assign_bit(FLAG_IS_OUT, &desc->flags, !ret); return ret; } -- 2.53.0