Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1435200

[PATCH] fs: configfs: don't set buffer_needs_fill to zero if show() returns error

Path csiph.com!news.mixmin.net!aioe.org!gothmog.csi.it!bofh.it!news.nic.it!robomod
From Tal Shorer <tal.shorer@gmail.com>
Newsgroups linux.kernel
Subject [PATCH] fs: configfs: don't set buffer_needs_fill to zero if show() returns error
Date Fri, 01 Jul 2016 11:30:02 +0200
Message-ID <rQ2VQ-4RO-7@gated-at.bofh.it> (permalink)
References <rPGBY-7Sr-7@gated-at.bofh.it>
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Ls3LHx1nSt0Yo0va3+Zw9wFkqxQvaTcbgKgDRdRgEPs=; b=dhruKPW5vussUetwq97tYUv/kT07QrNiy00CEPFxGOiXHG9i/lU7m4IY/zI6v3BY5P EKKiaR+s44dpcCcVvt44+77jPTmnAmsRvVFHVoySktCquiA2rsvARXc+hjHQUrLV2jJt 9phm8jtFZr0vQmQKeNKtn2/h56fRs4lXz4rXPaOFp1RcFvs7OcwaCHIh88ps11IhVqXw NWoPQFmT6yQaAwq4aLK1dJAF4b0w2P2BPqm1MwrTXsPEyjs5P/0TwMzPcBDW1XRiGVEQ GKvAZCw6DB/RfSscA7tyZhdJJ8ar+BghPHUV0403PLDZ7gaAe9h6HWtlrlnjZUEFnb3j 8Pdg==
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Ls3LHx1nSt0Yo0va3+Zw9wFkqxQvaTcbgKgDRdRgEPs=; b=Scr7Rwov+SVRlk63W8RardDsP+w+2AHVTTQYggHCjh5DuCTXIOb5wMKEHNr2VHWP8D YKs9IecFNJSIZ8d0/N0Hr7IEXOTlESPxA4JxY9ppc830wLwBDSg2ScGobc4K5pAyf0ro +M/Em+OL99Z2wuz7FE/+dVBIsv/6Te/lQTJKTr3tgk9I/M8NXeJtfTHIdVBIe1EsfPat dTjvmrQZRi3jLTUaM9/4NxfJxUYglTCe6xGuCmcgPh7mNdxHySqbOocAW3uTmdNdcu4P hgEP/lIx2PHiJ7QudgvJ5uD32Vi6dGQaStQLfXxmpk7+IOuxsvNW812SOJ7HjP7jDRJ5 uJ0Q==
X-Gm-Message-State ALyK8tJx981UBBgwIsjQnIJ26BYyaruIKQ81GwX0+T9OMogA8UQXr3G7gTUnYq/Niy+6tA==
X-Received by 10.194.95.74 with SMTP id di10mr2678764wjb.52.1467365355817; Fri, 01 Jul 2016 02:29:15 -0700 (PDT)
X-Mailer git-send-email 2.7.4
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 38
Organization linux.* mail to news gateway
X-Original-Cc Tal Shorer <tal.shorer@gmail.com>
X-Original-Date Fri, 1 Jul 2016 12:28:57 +0300
X-Original-Message-ID <1467365337-6712-1-git-send-email-tal.shorer@gmail.com>
X-Original-References <20160630093232.GA9287@lst.de>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1435200

Show key headers only | View raw


A confgifs attribute's show() callback is called once the first time
the user attempts to read from it. If it returns an error, that
error is returned to the user. However, the open file's
buffer_needs_fill is still set to zero and consecutive read() calls
will find an empty buffer that doesn't need filling and return 0 to
the user. This could give the user the wrong impression that the
attribute was read successfully.

Fix this by not setting buffer_needs_fill if show() returns an error,
making consecutive read() calls call show() again and either get an
error again or get data.

Signed-off-by: Tal Shorer <tal.shorer@gmail.com>
---
 fs/configfs/file.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/configfs/file.c b/fs/configfs/file.c
index 33b7ee3..68645c9 100644
--- a/fs/configfs/file.c
+++ b/fs/configfs/file.c
@@ -80,11 +80,11 @@ static int fill_read_buffer(struct dentry * dentry, struct configfs_buffer * buf
 
 	count = attr->show(item, buffer->page);
 
-	buffer->needs_read_fill = 0;
 	BUG_ON(count > (ssize_t)SIMPLE_ATTR_SIZE);
-	if (count >= 0)
+	if (count >= 0) {
+		buffer->needs_read_fill = 0;
 		buffer->count = count;
-	else
+	} else
 		ret = count;
 	return ret;
 }
-- 
2.7.4

Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Possible unwanted behaviour in configfs Tal Shorer <tal.shorer@gmail.com> - 2016-06-25 11:50 +0200
  Re: Possible unwanted behaviour in configfs Christoph Hellwig <hch@lst.de> - 2016-06-30 11:40 +0200
    [PATCH] fs: configfs: don't set buffer_needs_fill to zero if show() returns error Tal Shorer <tal.shorer@gmail.com> - 2016-07-01 11:30 +0200

csiph-web