@@ -1381,7 +1381,6 @@ static int ovl_rename(struct mnt_idmap *idmap, struct inode *olddir,
13811381static int ovl_create_tmpfile (struct file * file , struct dentry * dentry ,
13821382 struct inode * inode , umode_t mode )
13831383{
1384- const struct cred * new_cred __free (put_cred ) = NULL ;
13851384 struct path realparentpath ;
13861385 struct file * realfile ;
13871386 struct ovl_file * of ;
@@ -1390,33 +1389,34 @@ static int ovl_create_tmpfile(struct file *file, struct dentry *dentry,
13901389 int flags = file -> f_flags | OVL_OPEN_FLAGS ;
13911390 int err ;
13921391
1393- scoped_class ( override_creds_ovl , old_cred , dentry -> d_sb ) {
1394- new_cred = ovl_setup_cred_for_create ( dentry , inode , mode , old_cred );
1395- if (IS_ERR (new_cred ))
1396- return PTR_ERR (new_cred );
1397-
1398- ovl_path_upper (dentry -> d_parent , & realparentpath );
1399- realfile = backing_tmpfile_open (& file -> f_path , flags , & realparentpath ,
1400- mode , current_cred ());
1401- err = PTR_ERR_OR_ZERO (realfile );
1402- pr_debug ("tmpfile/open(%pd2, 0%o) = %i\n" , realparentpath .dentry , mode , err );
1403- if (err )
1404- return err ;
1392+ with_ovl_creds ( dentry -> d_sb ) {
1393+ scoped_class ( ovl_override_creator_creds , cred , dentry , inode , mode ) {
1394+ if (IS_ERR (cred ))
1395+ return PTR_ERR (cred );
1396+
1397+ ovl_path_upper (dentry -> d_parent , & realparentpath );
1398+ realfile = backing_tmpfile_open (& file -> f_path , flags , & realparentpath ,
1399+ mode , current_cred ());
1400+ err = PTR_ERR_OR_ZERO (realfile );
1401+ pr_debug ("tmpfile/open(%pd2, 0%o) = %i\n" , realparentpath .dentry , mode , err );
1402+ if (err )
1403+ return err ;
14051404
1406- of = ovl_file_alloc (realfile );
1407- if (!of ) {
1408- fput (realfile );
1409- return - ENOMEM ;
1410- }
1405+ of = ovl_file_alloc (realfile );
1406+ if (!of ) {
1407+ fput (realfile );
1408+ return - ENOMEM ;
1409+ }
14111410
1412- /* ovl_instantiate() consumes the newdentry reference on success */
1413- newdentry = dget (realfile -> f_path .dentry );
1414- err = ovl_instantiate (dentry , inode , newdentry , false, file );
1415- if (!err ) {
1416- file -> private_data = of ;
1417- } else {
1418- dput (newdentry );
1419- ovl_file_free (of );
1411+ /* ovl_instantiate() consumes the newdentry reference on success */
1412+ newdentry = dget (realfile -> f_path .dentry );
1413+ err = ovl_instantiate (dentry , inode , newdentry , false, file );
1414+ if (!err ) {
1415+ file -> private_data = of ;
1416+ } else {
1417+ dput (newdentry );
1418+ ovl_file_free (of );
1419+ }
14201420 }
14211421 }
14221422 return err ;
0 commit comments