Skip to content

Commit 33ab231

Browse files
committed
fs: don't assume arguments are non-NULL
The helper is explicitly documented as locking zero, one, or two arguments. While all current callers do pass non-NULL arguments there's no need or requirement for them to do so according to the code and the unlock_two_nondirectories() helper is pretty clear about it as well. So only call WARN_ON_ONCE() if the checked inode is valid. Fixes: 2454ad8 ("fs: Restrict lock_two_nondirectories() to non-directory inodes") Reviewed-by: Jan Kara <[email protected]> Cc: Jan Kara <[email protected]> Message-Id: <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent 66d8fc0 commit 33ab231

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

fs/inode.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,8 +1156,10 @@ void lock_two_inodes(struct inode *inode1, struct inode *inode2,
11561156
*/
11571157
void lock_two_nondirectories(struct inode *inode1, struct inode *inode2)
11581158
{
1159-
WARN_ON_ONCE(S_ISDIR(inode1->i_mode));
1160-
WARN_ON_ONCE(S_ISDIR(inode2->i_mode));
1159+
if (inode1)
1160+
WARN_ON_ONCE(S_ISDIR(inode1->i_mode));
1161+
if (inode2)
1162+
WARN_ON_ONCE(S_ISDIR(inode2->i_mode));
11611163
lock_two_inodes(inode1, inode2, I_MUTEX_NORMAL, I_MUTEX_NONDIR2);
11621164
}
11631165
EXPORT_SYMBOL(lock_two_nondirectories);

0 commit comments

Comments
 (0)