diff options
author | Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> | 2009-04-06 22:01:55 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-04-07 11:31:19 -0400 |
commit | 1f5abe7e7dbcd83e73212c6cb135a6106cea6a0b (patch) | |
tree | f80e97297d5badebd31bbb17003d76a4ea30453a /fs/nilfs2/direct.c | |
parent | 2c2e52fc4fca251e68f90821c9ff5cb18be4df58 (diff) |
nilfs2: replace BUG_ON and BUG calls triggerable from ioctl
Pekka Enberg advised me:
> It would be nice if BUG(), BUG_ON(), and panic() calls would be
> converted to proper error handling using WARN_ON() calls. The BUG()
> call in nilfs_cpfile_delete_checkpoints(), for example, looks to be
> triggerable from user-space via the ioctl() system call.
This will follow the comment and keep them to a minimum.
Acked-by: Pekka Enberg <penberg@cs.helsinki.fi>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/nilfs2/direct.c')
-rw-r--r-- | fs/nilfs2/direct.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/fs/nilfs2/direct.c b/fs/nilfs2/direct.c index e3ec24850089..c6379e482781 100644 --- a/fs/nilfs2/direct.c +++ b/fs/nilfs2/direct.c | |||
@@ -210,7 +210,6 @@ static int nilfs_direct_last_key(const struct nilfs_bmap *bmap, __u64 *keyp) | |||
210 | if (lastkey == NILFS_DIRECT_KEY_MAX + 1) | 210 | if (lastkey == NILFS_DIRECT_KEY_MAX + 1) |
211 | return -ENOENT; | 211 | return -ENOENT; |
212 | 212 | ||
213 | BUG_ON(keyp == NULL); | ||
214 | *keyp = lastkey; | 213 | *keyp = lastkey; |
215 | 214 | ||
216 | return 0; | 215 | return 0; |
@@ -366,9 +365,17 @@ static int nilfs_direct_assign(struct nilfs_bmap *bmap, | |||
366 | 365 | ||
367 | direct = (struct nilfs_direct *)bmap; | 366 | direct = (struct nilfs_direct *)bmap; |
368 | key = nilfs_bmap_data_get_key(bmap, *bh); | 367 | key = nilfs_bmap_data_get_key(bmap, *bh); |
369 | BUG_ON(key > NILFS_DIRECT_KEY_MAX); | 368 | if (unlikely(key > NILFS_DIRECT_KEY_MAX)) { |
369 | printk(KERN_CRIT "%s: invalid key: %llu\n", __func__, | ||
370 | (unsigned long long)key); | ||
371 | return -EINVAL; | ||
372 | } | ||
370 | ptr = nilfs_direct_get_ptr(direct, key); | 373 | ptr = nilfs_direct_get_ptr(direct, key); |
371 | BUG_ON(ptr == NILFS_BMAP_INVALID_PTR); | 374 | if (unlikely(ptr == NILFS_BMAP_INVALID_PTR)) { |
375 | printk(KERN_CRIT "%s: invalid pointer: %llu\n", __func__, | ||
376 | (unsigned long long)ptr); | ||
377 | return -EINVAL; | ||
378 | } | ||
372 | 379 | ||
373 | return direct->d_ops->dop_assign(direct, key, ptr, bh, | 380 | return direct->d_ops->dop_assign(direct, key, ptr, bh, |
374 | blocknr, binfo); | 381 | blocknr, binfo); |