All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marcin Slusarz <marcin.slusarz@gmail.com>
To: Bob Copeland <me@bobcopeland.com>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	akpm@linux-foundation.org
Subject: Re: [PATCH 2/7] omfs: add inode routines
Date: Tue, 15 Apr 2008 20:30:59 +0200	[thread overview]
Message-ID: <20080415183054.GA7176@joi> (raw)
In-Reply-To: <1208041121-26787-3-git-send-email-me@bobcopeland.com>

On Sat, Apr 12, 2008 at 06:58:36PM -0400, Bob Copeland wrote:
> +static int omfs_fill_super(struct super_block *sb, void *data, int silent)
> +{
> +	struct buffer_head *bh = NULL, *bh2 = NULL;
> +	struct omfs_super_block *omfs_sb;
> +	struct omfs_root_block *omfs_rb;
> +	struct omfs_sb_info *sbi;
> +	struct inode *root;
> +	sector_t start;
> +	int ret = 0;
> +
> +	sbi = kzalloc(sizeof(struct omfs_sb_info), GFP_KERNEL);
> +	if (!sbi)
> +		return -ENOMEM;
> +	sb->s_fs_info = sbi;
> +
> +	sb->s_maxbytes = 0xffffffff;
> +
> +	sb_set_blocksize(sb, 0x200);
> +
> +	bh = sb_bread(sb, 0);
> +	if (!bh)
> +		goto out;
> +
> +	omfs_sb = (struct omfs_super_block *)bh->b_data;
> +
> +	if (be32_to_cpu(omfs_sb->s_magic) != OMFS_MAGIC) {

can be omfs_sb->s_magic != cpu_to_be32(OMFS_MAGIC)
(cpu_to_be32 can be optimized away even on LE)


> +		if (!silent)
> +			printk(KERN_ERR "omfs: Invalid superblock (%x)\n",
> +				   omfs_sb->s_magic);
> +		goto out;
> +	}
> +	sb->s_magic = OMFS_MAGIC;
> +
> +	sbi->s_num_blocks = be64_to_cpu(omfs_sb->s_num_blocks);
> +	sbi->s_blocksize = be32_to_cpu(omfs_sb->s_blocksize);
> +	sbi->s_mirrors = be32_to_cpu(omfs_sb->s_mirrors);
> +	sbi->s_root_ino = be64_to_cpu(omfs_sb->s_root_block);
> +	sbi->s_sys_blocksize = be32_to_cpu(omfs_sb->s_sys_blocksize);
> +	mutex_init(&sbi->s_bitmap_lock);
> +
> +	/*
> +	 * Use sys_blocksize as the fs block since it is smaller than a
> +	 * page while the fs blocksize can be larger.
> +	 */
> +	sb_set_blocksize(sb, sbi->s_sys_blocksize);
> +
> +	/*
> +	 * ...and the difference goes into a shift.  sys_blocksize is always
> +	 * a power of two factor of blocksize.
> +	 */
> +	set_block_shift(sbi);
> +
> +	start = clus_to_blk(sbi, be64_to_cpu(omfs_sb->s_root_block));
> +	bh2 = sb_bread(sb, start);
> +	if (!bh2)
> +		goto out;
> +
> +	omfs_rb = (struct omfs_root_block *)bh2->b_data;
> +
> +	sbi->s_bitmap_ino = be64_to_cpu(omfs_rb->r_bitmap);
> +	sbi->s_clustersize = be32_to_cpu(omfs_rb->r_clustersize);
> +
> +	ret = omfs_get_imap(sb);
> +	if (ret)
> +		goto end;
> +
> +	sb->s_op = &omfs_sops;
> +
> +	root = omfs_iget(sb, be64_to_cpu(omfs_rb->r_root_dir));
> +	if (IS_ERR(root)) {
> +		ret = PTR_ERR(root);
> +		goto end;
> +	}
> +
> +	sb->s_root = d_alloc_root(root);
> +	if (!sb->s_root) {
> +		iput(root);
> +		goto out;
> +	}
> +	printk(KERN_DEBUG "omfs: Mounted volume %s\n", omfs_rb->r_name);
> +	goto end;
> +
> +out:
> +	ret = -EINVAL;
> +
> +end:
> +	if (bh2)
> +		brelse(bh2);
> +	if (bh)
> +		brelse(bh);
brelse(NULL) is safe to call

> +	return ret;
> +}
> +

this code leaks omfs_sbi_info (sbi)

  parent reply	other threads:[~2008-04-15 18:38 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-12 22:58 [PATCH 2/7] omfs: add inode routines Bob Copeland
2008-04-13  8:05 ` Christoph Hellwig
2008-04-13  9:17 ` Alan Cox
2008-04-15 18:03 ` Miklos Szeredi
2008-04-15 18:33   ` Bob Copeland
2008-04-15 18:30 ` Marcin Slusarz [this message]
2008-04-15 23:56   ` Bob Copeland
2008-04-16 18:31     ` Marcin Slusarz
  -- strict thread matches above, loose matches on Subject: below --
2008-03-27  0:45 Bob Copeland
2008-03-27  6:13 ` Andi Kleen
2008-03-27 12:38   ` Bob Copeland
2008-03-28  3:42 ` Arnd Bergmann
2008-03-28  3:42   ` Arnd Bergmann
2008-03-28 13:34   ` Bob Copeland
2008-03-28 20:20 ` Pavel Machek
2008-03-30  3:21   ` Bob Copeland

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=20080415183054.GA7176@joi \
    --to=marcin.slusarz@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=me@bobcopeland.com \
    /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.