linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs: remove redundant inode null check
@ 2016-12-16 15:24 Colin King
  2016-12-20 15:46 ` David Sterba
  0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2016-12-16 15:24 UTC (permalink / raw)
  To: Chris Mason, Josef Bacik, David Sterba, Jeff Mahoney, linux-btrfs
  Cc: linux-kernel

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.

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).

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

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] btrfs: remove redundant inode null check
  2016-12-16 15:24 [PATCH] btrfs: remove redundant inode null check Colin King
@ 2016-12-20 15:46 ` David Sterba
  0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2016-12-20 15:46 UTC (permalink / raw)
  To: Colin King
  Cc: Chris Mason, Josef Bacik, David Sterba, Jeff Mahoney,
	linux-btrfs, linux-kernel

On Fri, Dec 16, 2016 at 03:24:46PM +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.

This also means that the if (!dir) check is redundant. I've looked up
the call chain and haven't seen any instance that would lead to a NULL
dir down in the filesystem callback. So please remove both.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-12-20 15:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-16 15:24 [PATCH] btrfs: remove redundant inode null check Colin King
2016-12-20 15:46 ` David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).