From patchwork Sat Aug 15 12:07:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Bernat X-Patchwork-Id: 7020761 X-Patchwork-Delegate: ericvh@gmail.com Return-Path: X-Original-To: patchwork-v9fs-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0E151C05AC for ; Sat, 15 Aug 2015 12:08:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 442D7204A7 for ; Sat, 15 Aug 2015 12:08:13 +0000 (UTC) Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A806320461 for ; Sat, 15 Aug 2015 12:08:11 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-4.v29.ch3.sourceforge.com) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1ZQaFu-0007Za-PB; Sat, 15 Aug 2015 12:08:10 +0000 Received: from sog-mx-2.v43.ch3.sourceforge.com ([172.29.43.192] helo=mx.sourceforge.net) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1ZQaFt-0007ZR-DZ for v9fs-developer@lists.sourceforge.net; Sat, 15 Aug 2015 12:08:09 +0000 Received-SPF: pass (sog-mx-2.v43.ch3.sourceforge.com: domain of luffy.cx designates 78.47.78.131 as permitted sender) client-ip=78.47.78.131; envelope-from=bernat@luffy.cx; helo=bart.luffy.cx; Received: from bart.luffy.cx ([78.47.78.131]) by sog-mx-2.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1ZQaFq-0007Qd-5n for v9fs-developer@lists.sourceforge.net; Sat, 15 Aug 2015 12:08:09 +0000 Received: from bart.luffy.cx (localhost [127.0.0.1]) by bart.luffy.cx (Postfix) with ESMTP id E108414170; Sat, 15 Aug 2015 14:07:59 +0200 (CEST) Received: from zoro.exoscale.ch (unknown [IPv6:2001:7c0:dc15:72:ea2a:eaff:fe05:c0df]) by bart.luffy.cx (Postfix) with ESMTPS id A01FD1416B; Sat, 15 Aug 2015 14:07:59 +0200 (CEST) Received: by zoro.exoscale.ch (Postfix, from userid 1000) id A26BE4B8; Sat, 15 Aug 2015 14:07:55 +0200 (CEST) From: Vincent Bernat To: Eric Van Hensbergen , Ron Minnich , Latchesar Ionkov , v9fs-developer@lists.sourceforge.net, Al Viro Date: Sat, 15 Aug 2015 14:07:44 +0200 Message-Id: <1439640464-785-1-git-send-email-vincent@bernat.im> X-Mailer: git-send-email 2.5.0 In-Reply-To: <87bne8ix1m.fsf@zoro.exoscale.ch> References: <87bne8ix1m.fsf@zoro.exoscale.ch> X-Spam-Score: -1.5 (-) X-Headers-End: 1ZQaFq-0007Qd-5n Cc: Vincent Bernat Subject: [V9fs-developer] [PATCH] 9p: fix return code of read() when count is 0 X-BeenThere: v9fs-developer@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: v9fs-developer-bounces@lists.sourceforge.net X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When reading 0 bytes from an empty file on a 9P filesystem, the return code of read() was not 0 as expected due to an unitialized err variable. Tested with this simple program: #include #include #include #include #include int main(int argc, const char **argv) { assert(argc == 2); char buffer[256]; int fd = open(argv[1], O_RDONLY|O_NOCTTY); assert(fd >= 0); assert(read(fd, buffer, 0) == 0); return 0; } Signed-off-by: Vincent Bernat --- fs/9p/vfs_file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c index 1ef16bd8280b..3abc447783aa 100644 --- a/fs/9p/vfs_file.c +++ b/fs/9p/vfs_file.c @@ -381,7 +381,7 @@ static ssize_t v9fs_file_read_iter(struct kiocb *iocb, struct iov_iter *to) { struct p9_fid *fid = iocb->ki_filp->private_data; - int ret, err; + int ret, err = 0; p9_debug(P9_DEBUG_VFS, "count %zu offset %lld\n", iov_iter_count(to), iocb->ki_pos);