mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Oliver Neukum <oliver@neukum.name>
To: gregkh@suse.de, Alan Stern <stern@rowland.harvard.edu>,
	maneesh@in.ibm.com, linux-kernel@vger.kernel.org
Subject: error handling in sysfs, fill_read_buffer()
Date: Tue, 2 Jan 2007 08:48:08 +0100 (MET)	[thread overview]
Message-ID: <200701020850.28724.oliver@neukum.name> (raw)

Hi,

if a driver returns an error in fill_read_buffer(), the buffer will be
marked as filled. Subsequent reads will return eof. But there is
no data because of an error, not because it has been read.
Not marking the buffer filled is the obvious fix.

	Regards
		Oliver

Signed-off-by: Oliver Neukum <oliver@neukum.name>
--

--- a/fs/sysfs/file.c	2006-12-24 05:00:32.000000000 +0100
+++ b/fs/sysfs/file.c	2007-01-01 15:03:14.000000000 +0100
@@ -70,7 +70,8 @@
  *	Allocate @buffer->page, if it hasn't been already, then call the
  *	kobject's show() method to fill the buffer with this attribute's 
  *	data. 
- *	This is called only once, on the file's first read. 
+ *	This is called only once, on the file's first read unless an error
+ *	is returned.
  */
 static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer)
 {
@@ -88,12 +89,13 @@
 
 	buffer->event = atomic_read(&sd->s_event);
 	count = ops->show(kobj,attr,buffer->page);
-	buffer->needs_read_fill = 0;
 	BUG_ON(count > (ssize_t)PAGE_SIZE);
-	if (count >= 0)
+	if (count >= 0) {
+		buffer->needs_read_fill = 0;
 		buffer->count = count;
-	else
+	} else {
 		ret = count;
+	}
 	return ret;
 }
 

             reply	other threads:[~2007-01-02  7:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-02  7:48 Oliver Neukum [this message]
2007-01-02 15:26 ` Alan Stern
2007-01-02 15:38   ` Oliver Neukum
2007-01-02 15:47     ` Alan Stern
2007-01-02 15:53       ` Oliver Neukum

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=200701020850.28724.oliver@neukum.name \
    --to=oliver@neukum.name \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maneesh@in.ibm.com \
    --cc=stern@rowland.harvard.edu \
    /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

all inboxes | Powered by JetHome®