From: Tal Shorer <tal.shorer@gmail.com>
To: jlbec@evilplan.org, hch@lst.de, linux-kernel@vger.kernel.org
Cc: Tal Shorer <tal.shorer@gmail.com>
Subject: [PATCH] fs: configfs: don't set buffer_needs_fill to zero if show() returns error
Date: Fri, 1 Jul 2016 12:28:57 +0300 [thread overview]
Message-ID: <1467365337-6712-1-git-send-email-tal.shorer@gmail.com> (raw)
In-Reply-To: <20160630093232.GA9287@lst.de>
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
next prev parent reply other threads:[~2016-07-01 9:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-25 9:43 Possible unwanted behaviour in configfs Tal Shorer
2016-06-30 9:32 ` Christoph Hellwig
2016-07-01 9:28 ` Tal Shorer [this message]
2016-07-26 18:23 ` [PATCH] fs: configfs: don't set buffer_needs_fill to zero if show() returns error Tal Shorer
2016-07-27 11:30 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1467365337-6712-1-git-send-email-tal.shorer@gmail.com \
--to=tal.shorer@gmail.com \
--cc=hch@lst.de \
--cc=jlbec@evilplan.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).