From patchwork Tue Oct 21 02:00:48 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: roel kluin X-Patchwork-Id: 5134 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id BAEDFDDDE1 for ; Tue, 21 Oct 2008 07:00:58 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753467AbYJTUA4 (ORCPT ); Mon, 20 Oct 2008 16:00:56 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753458AbYJTUA4 (ORCPT ); Mon, 20 Oct 2008 16:00:56 -0400 Received: from ey-out-2122.google.com ([74.125.78.26]:35453 "EHLO ey-out-2122.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752438AbYJTUAy (ORCPT ); Mon, 20 Oct 2008 16:00:54 -0400 Received: by ey-out-2122.google.com with SMTP id 6so639175eyi.37 for ; Mon, 20 Oct 2008 13:00:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:cc:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=gxLHG7/GuXJ6fZf1zbT+LHKFU/pexHcGDQ1YoYA47h8=; b=perYeIICpnl1XNluBWWe8n305FV94NpIZKd/4t56yHJamrW9xab05gONqKGVgxuIHo ueGXgfBpwkcERDgg4vIn3Jc9twtWP3Y3bByR4Irp5rlXezcH9gXdRhQoPgfmShADcwBr ZswBZh9nOYex9kgh1C96o2P/gDfMoNgDuz1As= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; b=h9j1ktWDnuEoiyMfPX2Dm2w9/PmP81zKxUHaiA/oN1iTmBp/gVVeGjneNHtDNET4nW NlqgjQIkw0ELnn7e+sZgpwqzElT/9FjfYuX+iPH0bYB2uyF1x2n3jdDSAFGug9g/9ERf V0gPAaQon9ZiAPhoqaPDy9sX5ti5nSGEzLGaM= Received: by 10.210.92.8 with SMTP id p8mr4686432ebb.101.1224532852030; Mon, 20 Oct 2008 13:00:52 -0700 (PDT) Received: from ?192.168.1.117? (d133062.upc-d.chello.nl [213.46.133.62]) by mx.google.com with ESMTPS id z34sm6827232ikz.3.2008.10.20.13.00.50 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 20 Oct 2008 13:00:51 -0700 (PDT) Message-ID: <48FD37D0.6030509@gmail.com> Date: Mon, 20 Oct 2008 22:00:48 -0400 From: roel kluin User-Agent: Mozilla-Thunderbird 2.0.0.9 (X11/20080110) MIME-Version: 1.0 To: Theodore Tso CC: linux-ext4@vger.kernel.org Subject: Re: [PATCH] ext4: simple_strtol returns signed. References: <48FA4558.2020603@gmail.com> <20081018143610.GA8383@mit.edu> In-Reply-To: <20081018143610.GA8383@mit.edu> Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 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 --- 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? -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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; }