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=1796389172; b=FGkFwH4liGS7gAqcU5qTX067n5OlaUiy0KVsf3RHR2E1gNIa0YqYRjmqOi2QY4O/GsP+ NWhYzsmE6XXKLbuFmHn7l6UKs+RHdtzberwa6EWjq+iuT7FifqnUUmJFKIoUMM8OzYJ3P wuZCmDpkUSQWnuyqV81CAYHMnzjyQM4zhjHrGuYJ6uRSk8it/Cp+Aq/mrx+jBnPs6k/we /wDLkmFab/gY39/VTBHoulrh6nSBEXEf622d3FQkTaGFkb+HfVv9mHuyhiJagEf4Ivi9X /N8IWcNMh7ViGodvslqM+NY3z6pENmua0eNT6EWW98ZplhDyQ8nsJSSiXo07mGVD1hQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796389172; 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=UmaWqmjP1WqQ8kcYZMWs5qTzZRxi2LpNNkfq28GGl9g=; b=P69mYFqDbpkTOti4sXjcOYTEOorkoyO0Jpe+r8qMIUZca9e0ZsBVKv8ADQXtzitZ+umG GESvEF0OPCE2knvAlSdVH9UdawxXrNKBeqktX+mgTuD2dDtk0mOZ0FRfX9yExL+/Syxef iP98ulmFTEApqa/JP2jvo4739tgKkjgq/8h9JCX1uvAeUnmouHTvE6Mu2IUBE2TR2V2xQ mdUZnQkcz9/OBVjNg7vW73upjbec8D/S7Hliu8x1w9BefBSvHP7sXpzokitSIPSHtFgMh Ty6VNuBRlWNcXiXxZPw+cpzNIOF6SU4AmcUVDnt5TR46y+pH7t/0XFKlZnC8fu0e6hw== 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=cbapBeUu; 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 596EB606A322; Fri, 4 Dec 2026 12:59:32 +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=cbapBeUu Received: by smtp.kernel.org (Postfix) with ESMTPSA id B4B761F00897; Fri, 4 Dec 2026 12:59:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796389172; bh=UmaWqmjP1WqQ8kcYZMWs5qTzZRxi2LpNNkfq28GGl9g=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=cbapBeUu8YRG2DXK8Yf7WQzGAEbjDeBpRa6oNEGQPanwZGwytkwz/My12XUTWm3H4 eyckWLluQWi0GgoIAz1g3UYzZ//TaEJfYT3lkRn7nrJfKsKJgejPOn4vkzlVCjvizO ns31eNIKKaIEU7yT+ZIsJYeTFLlu6KhX479ljtBQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Zhu Jun , Bartosz Golaszewski , Sasha Levin Subject: [PATCH 6.1 0850/1059] tools: gpio: Preserve device listing errors in lsgpio Date: Fri, 4 Dec 2026 19:06:21 +0900 Message-ID: <20261204100706.046609957@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: Zhu Jun [ Upstream commit 809117fc28453aafa7164ad45ea853f900974d08 ] When no chip is selected, lsgpio breaks out of the directory scan on a list_device() failure, then unconditionally resets ret to zero. A chip that cannot be opened or queried is therefore reported as success. Initialize ret to zero before scanning instead, so an empty scan still succeeds and errors from list_device() reach the caller. Fixes: 6d591c46bce0 ("tools/gpio: create GPIO tools") Signed-off-by: Zhu Jun Link: https://patch.msgid.link/20261120062053.98356-1-zhujun2@cmss.chinamobile.com Signed-off-by: Bartosz Golaszewski Signed-off-by: Sasha Levin --- tools/gpio/lsgpio.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/gpio/lsgpio.c b/tools/gpio/lsgpio.c index 52a0be45410c9..de2eccc134796 100644 --- a/tools/gpio/lsgpio.c +++ b/tools/gpio/lsgpio.c @@ -205,7 +205,7 @@ int main(int argc, char **argv) goto error_out; } - ret = -ENOENT; + ret = 0; while (ent = readdir(dp), ent) { if (check_prefix(ent->d_name, "gpiochip")) { ret = list_device(ent->d_name); @@ -214,7 +214,6 @@ int main(int argc, char **argv) } } - ret = 0; if (closedir(dp) == -1) { perror("scanning devices: Failed to close directory"); ret = -errno; -- 2.53.0