* [PATCH] btrfs: remove unnecessary NULL check for the new inode during rename exchange
@ 2021-07-29 14:28 fdmanana
2021-07-29 17:27 ` David Sterba
0 siblings, 1 reply; 2+ messages in thread
From: fdmanana @ 2021-07-29 14:28 UTC (permalink / raw)
To: linux-btrfs
From: Filipe Manana <fdmanana@suse.com>
At the very end of btrfs_rename_exchange(), in case an error happened, we
are checking if 'new_inode' is NULL, but that is not needed since during a
rename exchange, unlike regular renames, 'new_inode' can never be NULL,
and if it were, we would have a crash much earlier when we dereference it
multiple times.
So remove the check because it is not necessary and because it is causing
static checkers to emit a warning. I probably introduced the check by
copy-pasting similar code from btrfs_rename(), where 'new_inode' can be
NULL, in commit 86e8aa0e772cab ("Btrfs: unpin logs if rename exchange
operation fails").
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
fs/btrfs/inode.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 59b35e12bb81..ef76bde10913 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -9421,8 +9421,7 @@ static int btrfs_rename_exchange(struct inode *old_dir,
if (btrfs_inode_in_log(BTRFS_I(old_dir), fs_info->generation) ||
btrfs_inode_in_log(BTRFS_I(new_dir), fs_info->generation) ||
btrfs_inode_in_log(BTRFS_I(old_inode), fs_info->generation) ||
- (new_inode &&
- btrfs_inode_in_log(BTRFS_I(new_inode), fs_info->generation)))
+ btrfs_inode_in_log(BTRFS_I(new_inode), fs_info->generation))
btrfs_set_log_full_commit(trans);
if (root_log_pinned) {
--
2.28.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] btrfs: remove unnecessary NULL check for the new inode during rename exchange
2021-07-29 14:28 [PATCH] btrfs: remove unnecessary NULL check for the new inode during rename exchange fdmanana
@ 2021-07-29 17:27 ` David Sterba
0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2021-07-29 17:27 UTC (permalink / raw)
To: fdmanana; +Cc: linux-btrfs
On Thu, Jul 29, 2021 at 03:28:34PM +0100, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
>
> At the very end of btrfs_rename_exchange(), in case an error happened, we
> are checking if 'new_inode' is NULL, but that is not needed since during a
> rename exchange, unlike regular renames, 'new_inode' can never be NULL,
> and if it were, we would have a crash much earlier when we dereference it
> multiple times.
>
> So remove the check because it is not necessary and because it is causing
> static checkers to emit a warning. I probably introduced the check by
> copy-pasting similar code from btrfs_rename(), where 'new_inode' can be
> NULL, in commit 86e8aa0e772cab ("Btrfs: unpin logs if rename exchange
> operation fails").
>
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Filipe Manana <fdmanana@suse.com>
Added to misc-next, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-07-29 17:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-29 14:28 [PATCH] btrfs: remove unnecessary NULL check for the new inode during rename exchange fdmanana
2021-07-29 17:27 ` 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).