From: Alexander Nyberg <alexn@dsv.su.se>
To: gregkh@suse.de
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] sysfs: Signedness problem
Date: Sun, 27 Feb 2005 14:25:23 +0100 [thread overview]
Message-ID: <1109510723.2295.3.camel@boxen> (raw)
count is size_t, fill_write_buffer() may return a negative number
which would evade the 'count > 0' checks and do bad things.
found by the Coverity tool
Signed-off-by: Alexander Nyberg <alexn@dsv.su.se>
===== fs/sysfs/file.c 1.22 vs edited =====
--- 1.22/fs/sysfs/file.c 2004-11-04 03:04:14 +01:00
+++ edited/fs/sysfs/file.c 2005-02-26 15:48:19 +01:00
@@ -231,15 +231,16 @@ static ssize_t
sysfs_write_file(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
{
struct sysfs_buffer * buffer = file->private_data;
+ ssize_t len;
down(&buffer->sem);
- count = fill_write_buffer(buffer,buf,count);
- if (count > 0)
- count = flush_write_buffer(file->f_dentry,buffer,count);
- if (count > 0)
- *ppos += count;
+ len = fill_write_buffer(buffer, buf, count);
+ if (len > 0)
+ len = flush_write_buffer(file->f_dentry, buffer, len);
+ if (len > 0)
+ *ppos += len;
up(&buffer->sem);
- return count;
+ return len;
}
static int check_perm(struct inode * inode, struct file * file)
reply other threads:[~2005-02-27 13:25 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1109510723.2295.3.camel@boxen \
--to=alexn@dsv.su.se \
--cc=gregkh@suse.de \
--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