All of lore.kernel.org
 help / color / mirror / Atom feed
From: roel kluin <roel.kluin@gmail.com>
To: Theodore Tso <tytso@mit.edu>
Cc: linux-ext4@vger.kernel.org
Subject: Re: [PATCH] ext4: simple_strtol returns signed.
Date: Mon, 20 Oct 2008 22:00:48 -0400	[thread overview]
Message-ID: <48FD37D0.6030509@gmail.com> (raw)
In-Reply-To: <20081018143610.GA8383@mit.edu>

simple_strtol returns signed, but a negative return values is lost when stored
in an unsigned. As suggested use simple_strtoul() instead. 

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
Since p is dereferenced with the unsigned long return of simple_strtoul, I think
p should be a pointer to an unsigned long, am I wrong?

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 9b2b2bc..0ab6cb4 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -3514,18 +3514,15 @@ static int ext4_ui_proc_open(struct inode *inode, struct file *file)
 static ssize_t ext4_ui_proc_write(struct file *file, const char __user *buf,
 			       size_t cnt, loff_t *ppos)
 {
-	unsigned int *p = PDE(file->f_path.dentry->d_inode)->data;
+	unsigned long *p = PDE(file->f_path.dentry->d_inode)->data;
 	char str[32];
-	unsigned long value;
 
 	if (cnt >= sizeof(str))
 		return -EINVAL;
 	if (copy_from_user(str, buf, cnt))
 		return -EFAULT;
-	value = simple_strtol(str, NULL, 0);
-	if (value < 0)
-		return -ERANGE;
-	*p = value;
+
+	*p = simple_strtoul(str, NULL, 0);
 	return cnt;
 }
 

      reply	other threads:[~2008-10-20 20:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-18 20:21 [PATCH] ext4: simple_strtol returns signed roel kluin
2008-10-18 14:36 ` Theodore Tso
2008-10-21  2:00   ` roel kluin [this message]

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=48FD37D0.6030509@gmail.com \
    --to=roel.kluin@gmail.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.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 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.