Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1545225 > unrolled thread

[PATCH][V2] btrfs: remove redundant inode null check

Started byColin King <colin.king@canonical.com>
First post2016-12-20 17:20 +0100
Last post2016-12-20 17:30 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH][V2] btrfs: remove redundant inode null check Colin King <colin.king@canonical.com> - 2016-12-20 17:20 +0100
    Re: [PATCH][V2] btrfs: remove redundant inode null check David Sterba <dsterba@suse.cz> - 2016-12-20 17:30 +0100

#1545225 — [PATCH][V2] btrfs: remove redundant inode null check

FromColin King <colin.king@canonical.com>
Date2016-12-20 17:20 +0100
Subject[PATCH][V2] btrfs: remove redundant inode null check
Message-ID<sQviW-7Qa-7@gated-at.bofh.it>
From: Colin Ian King <colin.king@canonical.com>

The check for a null inode is redundant since the function
is a callback for exportfs, which will itself crash if
dentry->d_inode or parent->d_inode is NULL.  Removing the
null check makes this consistent with other file systems.

Also remove the redundant null dir check too.

Found with static analysis by CoverityScan, CID 1389472

Kudos to Jeff Mahoney for reviewing and explaining the error in
my original patch (most of this explanation went into the above
commit message) and David Sterba for pointing out that the dir
check is also redundant.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 fs/btrfs/export.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/fs/btrfs/export.c b/fs/btrfs/export.c
index 340d907..4f77431 100644
--- a/fs/btrfs/export.c
+++ b/fs/btrfs/export.c
@@ -235,9 +235,6 @@ static int btrfs_get_name(struct dentry *parent, char *name,
 	int ret;
 	u64 ino;
 
-	if (!dir || !inode)
-		return -EINVAL;
-
 	if (!S_ISDIR(dir->i_mode))
 		return -EINVAL;
 
-- 
2.10.2

[toc] | [next] | [standalone]


#1545247

FromDavid Sterba <dsterba@suse.cz>
Date2016-12-20 17:30 +0100
Message-ID<sQvsB-7Tp-1@gated-at.bofh.it>
In reply to#1545225
On Tue, Dec 20, 2016 at 04:18:37PM +0000, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The check for a null inode is redundant since the function
> is a callback for exportfs, which will itself crash if
> dentry->d_inode or parent->d_inode is NULL.  Removing the
> null check makes this consistent with other file systems.
> 
> Also remove the redundant null dir check too.
> 
> Found with static analysis by CoverityScan, CID 1389472
> 
> Kudos to Jeff Mahoney for reviewing and explaining the error in
> my original patch (most of this explanation went into the above
> commit message) and David Sterba for pointing out that the dir
> check is also redundant.
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Reviewed-by: David Sterba <dsterba@suse.com>

Added to cleanups queue, thanks.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web