Tsutomu Itoh
2011-Jun-28 03:34 UTC
[PATCH] Btrfs: fix error check of btrfs_lookup_dentry()
The return value of btrfs_lookup_dentry is checked so that the panic such as illegal address reference should not occur. Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com> --- fs/btrfs/inode.c | 1 + fs/btrfs/ioctl.c | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 447612d..1364ae8 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -4082,6 +4082,7 @@ static struct dentry *btrfs_lookup(struct inode *dir, struct dentry *dentry, inode = btrfs_lookup_dentry(dir, dentry); if (IS_ERR(inode)) return ERR_CAST(inode); + BUG_ON(!inode); return d_splice_alias(inode, dentry); } diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index a3c4751..39c62d3 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -325,6 +325,7 @@ static noinline int create_subvol(struct btrfs_root *root, struct btrfs_root *new_root; struct dentry *parent = dget_parent(dentry); struct inode *dir; + struct inode *inode; int ret; int err; u64 objectid; @@ -437,7 +438,14 @@ static noinline int create_subvol(struct btrfs_root *root, BUG_ON(ret); - d_instantiate(dentry, btrfs_lookup_dentry(dir, dentry)); + inode = btrfs_lookup_dentry(dir, dentry); + if (IS_ERR(inode)) { + ret = PTR_ERR(inode); + goto fail; + } + BUG_ON(!inode); + + d_instantiate(dentry, inode); fail: dput(parent); if (async_transid) { -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Josef Bacik
2011-Jun-28 14:22 UTC
Re: [PATCH] Btrfs: fix error check of btrfs_lookup_dentry()
On 06/27/2011 11:34 PM, Tsutomu Itoh wrote:> The return value of btrfs_lookup_dentry is checked so that > the panic such as illegal address reference should not occur. > > Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>Nack, please fix btrfs_lookup_dentry to return ERR_PTR(-ENOENT) if it doesn''t find something. Thanks, Josef -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Tsutomu Itoh
2011-Jun-29 00:15 UTC
Re: [PATCH] Btrfs: fix error check of btrfs_lookup_dentry()
(2011/06/28 23:22), Josef Bacik wrote:> On 06/27/2011 11:34 PM, Tsutomu Itoh wrote: >> The return value of btrfs_lookup_dentry is checked so that >> the panic such as illegal address reference should not occur. >> >> Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com> > > Nack, please fix btrfs_lookup_dentry to return ERR_PTR(-ENOENT) if it > doesn''t find something. Thanks,OK, I will repost soon. Thanks, Tsutomu -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html