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=1796382028; b=XIwqpaKV1DPLr8D7EWLHeJulpfolBXumxGVj0GmHGH1zs+GCZt2DHhUHGyIG0NOQP9Mr IHZeAB+CKgesOFLiCEEEnZJGHv/IfbETX9dPn0iay4zML8+PhZs4bdCq5oiDp7epy06xp sLB1Phc08c0obLHM6/h/FlXcf/9KCnbJ5N/7WxJuS7+lAo+jDJU4rxlZmwWrY1JMj4+gr g1OY39hkZ+WB03Gwps9qQ81F0j7/O3Z6vgRTJC7x3to7tTuUZRZmes7ByE3HiEc1NL9rh 8SSKSfKHa3c9DGG+zp+0qpoTUDfzUv6sF/4aTwxmo7iyiDw0NZfM8+zg/awG9YFmLQg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382028; 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=MHpvF/cqUmCAA8BgMF5vUvXTsL+ZpB1snzSn/4WKSCs=; b=w7P3Neeo07o2IeEcTwktRLQ/H0jDwoGWIXmHELYD8INR75hKGVi/c2iPxdENuWdAgPbP EUFERt1aY4Ra9eVhZDWMoYI1jttInBbhC2jF1MKeQRz7vT2htSO37NneZ0MEu//QHvxRy vKpRAUKBKmJRFivgFpyf3CVlSmXpU2rrKVxkemXUDITPVfHgYegLm0imGvi5c+fkw9jQm NFanNblkP2hAcMcHx5T/W5g9JmcXpyXAkwReFMNDV0qziRqO43/VC2tZfHi8cPeoGzdNi acq9OwdsDvCgMHPL0i/7N04g1KgTMBJSy4lBSnpT5nvhtMom+kgjAORqi34MCL9tRnA== 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=oTwPyNTK; 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 D70FF606A32D; Fri, 4 Dec 2026 11:00:28 +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=oTwPyNTK Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4D1021F00934; Fri, 4 Dec 2026 11:00:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382028; bh=MHpvF/cqUmCAA8BgMF5vUvXTsL+ZpB1snzSn/4WKSCs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=oTwPyNTK7vFfCd6mYHmdswM2Cfox948dI5NkTZT0tw7O1gHPKTO0fcB4gKr27wIUY gbUKDpUNTx2VPX+T8UOqTGqJe6V0Z43bDBzh7IMowsFpTPLnxW1MaB07e6AlILJIM9 fbdy4wL/tT2nQqona/b4seq7iddI6giCDC9hO3t4= 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.18 236/703] tools: gpio: Preserve device listing errors in lsgpio Date: Fri, 4 Dec 2026 19:02:15 +0900 Message-ID: <20261204100634.092369079@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@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.18-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