public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: "Theodore Ts'o" <tytso@mit.edu>,
	Andreas Dilger <adilger.kernel@dilger.ca>,
	linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [patch] ext4: underflow in alignment check
Date: Mon, 20 Jun 2016 18:02:04 +0200	[thread overview]
Message-ID: <20160620160204.GG6882@quack2.suse.cz> (raw)
In-Reply-To: <20160616070709.GC23129@mwanda>

On Thu 16-06-16 10:07:09, Dan Carpenter wrote:
> My static checker complains that this can underflow if arg is negative
> which is true.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

How come? (1 << 30) fits even into 32-bit signed type. So where's the
problem?

								Honza

> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index b1a3471..a2a17e9 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -1576,7 +1576,7 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token,
>  	} else if (token == Opt_min_batch_time) {
>  		sbi->s_min_batch_time = arg;
>  	} else if (token == Opt_inode_readahead_blks) {
> -		if (arg && (arg > (1 << 30) || !is_power_of_2(arg))) {
> +		if (arg && (arg > (1U << 30) || !is_power_of_2(arg))) {
>  			ext4_msg(sb, KERN_ERR,
>  				 "EXT4-fs: inode_readahead_blks must be "
>  				 "0 or a power of 2 smaller than 2^31");
> --
> 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
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

  reply	other threads:[~2016-06-20 16:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-16  7:07 [patch] ext4: underflow in alignment check Dan Carpenter
2016-06-20 16:02 ` Jan Kara [this message]
2016-06-20 19:53   ` Dan Carpenter
2016-06-21  7:43     ` Jan Kara
2016-06-21 13:06       ` Dan Carpenter

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=20160620160204.GG6882@quack2.suse.cz \
    --to=jack@suse.cz \
    --cc=adilger.kernel@dilger.ca \
    --cc=dan.carpenter@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox