All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rusty Lynch <rusty@linux.co.intel.com>
To: Patrick Mochel <mochel@osdl.org>
Cc: lkml <linux-kernel@vger.kernel.org>
Subject: [PATCH]Fix to the new sysfs bin file support
Date: 05 Mar 2003 18:38:42 -0800	[thread overview]
Message-ID: <1046918323.2915.45.camel@vmhack> (raw)

I happen to notice the new binary file support in sysfs and had to take
for a spin.  If I understand this correct my write file will need to
allocate the buffer->data, but then I have no way of freeing that memory
since I don't get a release callback.

Here is a patch that:
* makes sysfs cleanup the buffer->data allocated by the attribute write
functions
* fixes a bug that causes the kernel to oops when somebody attempts to
write to the file.

BTW, would you be totally opposed to a patch that added open, release,
and ioctl to the list of functions supported by sysfs binary files?

Another question... How would a driver know that the various write and
read calls are coming from the same open, or would there be a way for a
driver to make it so that only one thing can open the sysfs file at a
time?
    --rustyl

--- fs/sysfs/bin.c.orig	2003-03-05 18:33:44.000000000 -0800
+++ fs/sysfs/bin.c	2003-03-05 18:34:01.000000000 -0800
@@ -50,6 +50,10 @@
 		ret = count;
 	}
  Done:
+	if (buffer && buffer->data) {
+		kfree(buffer->data);
+		buffer->data = NULL;
+	}
 	return ret;
 }
 
@@ -66,7 +70,7 @@
 static int fill_write(struct file * file, const char * userbuf, 
 		      struct sysfs_bin_buffer * buffer)
 {
-	return copy_from_user(buffer,userbuf,buffer->count) ?
+	return copy_from_user(buffer->data,userbuf,buffer->count) ?
 		-EFAULT : 0;
 }
 




             reply	other threads:[~2003-03-06  2:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-03-06  2:38 Rusty Lynch [this message]
2003-03-06 15:34 ` [PATCH]Fix to the new sysfs bin file support Patrick Mochel
2003-03-06 16:54   ` Rusty Lynch

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=1046918323.2915.45.camel@vmhack \
    --to=rusty@linux.co.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mochel@osdl.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.