diff --git a/fs/exec.c b/fs/exec.c
index c195ebb8e2aaa961d718fb2c800c3e029e0c0bbd..698a86094f7672550340c2e4ca20cdf97e8ee0e2 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1475,7 +1475,7 @@ static void bprm_fill_uid(struct linux_binprm *bprm)
 	if (task_no_new_privs(current))
 		return;
 
-	inode = file_inode(bprm->file);
+	inode = bprm->file->f_path.dentry->d_inode;
 	mode = READ_ONCE(inode->i_mode);
 	if (!(mode & (S_ISUID|S_ISGID)))
 		return;