From patchwork Sat Aug 15 13:49:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Bernat X-Patchwork-Id: 7020781 X-Patchwork-Delegate: ericvh@gmail.com Return-Path: X-Original-To: patchwork-v9fs-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CA1789F44C for ; Sat, 15 Aug 2015 13:49:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F0AAE205DC for ; Sat, 15 Aug 2015 13:49:45 +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 50A132062C for ; Sat, 15 Aug 2015 13:49:44 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-3.v29.ch3.sourceforge.com) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1ZQbqA-0002j8-UJ; Sat, 15 Aug 2015 13:49:42 +0000 Received: from sog-mx-1.v43.ch3.sourceforge.com ([172.29.43.191] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1ZQbq9-0002j2-Ld for v9fs-developer@lists.sourceforge.net; Sat, 15 Aug 2015 13:49:41 +0000 Received-SPF: pass (sog-mx-1.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-1.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1ZQbq7-0007bG-7g for v9fs-developer@lists.sourceforge.net; Sat, 15 Aug 2015 13:49:41 +0000 Received: from bart.luffy.cx (localhost [127.0.0.1]) by bart.luffy.cx (Postfix) with ESMTP id E58D514170; Sat, 15 Aug 2015 15:49:32 +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 BA10C1416B; Sat, 15 Aug 2015 15:49:32 +0200 (CEST) Received: by zoro.exoscale.ch (Postfix, from userid 1000) id E9F1E4B8; Sat, 15 Aug 2015 15:49:29 +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 15:49:13 +0200 Message-Id: <1439646553-24961-1-git-send-email-vincent@bernat.im> X-Mailer: git-send-email 2.5.0 In-Reply-To: <87y4hchdmy.fsf@zoro.exoscale.ch> References: <87y4hchdmy.fsf@zoro.exoscale.ch> X-Spam-Score: -1.5 (-) X-Headers-End: 1ZQbq7-0007bG-7g Cc: Vincent Bernat Subject: [V9fs-developer] [PATCH] 9p: ensure err is initialized to 0 in p9_client_read/write 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 Some use of those functions were providing unitialized values to those functions. Notably, when reading 0 bytes from an empty file on a 9P filesystem, the return code of read() was not 0. 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 --- net/9p/client.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/9p/client.c b/net/9p/client.c index 498454b3c06c..ea79ee9a7348 100644 --- a/net/9p/client.c +++ b/net/9p/client.c @@ -1541,6 +1541,7 @@ p9_client_read(struct p9_fid *fid, u64 offset, struct iov_iter *to, int *err) struct p9_client *clnt = fid->clnt; struct p9_req_t *req; int total = 0; + *err = 0; p9_debug(P9_DEBUG_9P, ">>> TREAD fid %d offset %llu %d\n", fid->fid, (unsigned long long) offset, (int)iov_iter_count(to)); @@ -1620,6 +1621,7 @@ p9_client_write(struct p9_fid *fid, u64 offset, struct iov_iter *from, int *err) struct p9_client *clnt = fid->clnt; struct p9_req_t *req; int total = 0; + *err = 0; p9_debug(P9_DEBUG_9P, ">>> TWRITE fid %d offset %llu count %zd\n", fid->fid, (unsigned long long) offset,