@@ -6491,7 +6491,6 @@ static int smb2_create_link(struct ksmbd_work *work,
6491
6491
#if LINUX_VERSION_CODE >= KERNEL_VERSION (6 , 4 , 0 )
6492
6492
struct path parent_path ;
6493
6493
#endif
6494
- bool file_present = false;
6495
6494
int rc ;
6496
6495
6497
6496
if (buf_len < (u64 )sizeof (struct smb2_file_link_info ) +
@@ -6529,14 +6528,10 @@ static int smb2_create_link(struct ksmbd_work *work,
6529
6528
if (rc != - ENOENT )
6530
6529
goto out ;
6531
6530
} else {
6532
- file_present = true;
6533
6531
#if LINUX_VERSION_CODE < KERNEL_VERSION (6 , 4 , 0 )
6534
6532
path_put (& path );
6535
6533
#endif
6536
- }
6537
-
6538
- if (file_info -> ReplaceIfExists ) {
6539
- if (file_present ) {
6534
+ if (file_info -> ReplaceIfExists ) {
6540
6535
#if LINUX_VERSION_CODE >= KERNEL_VERSION (6 , 4 , 0 )
6541
6536
rc = ksmbd_vfs_remove_file (work , & path );
6542
6537
#else
@@ -6548,23 +6543,20 @@ static int smb2_create_link(struct ksmbd_work *work,
6548
6543
link_name );
6549
6544
goto out ;
6550
6545
}
6551
- }
6552
- } else {
6553
- if (file_present ) {
6546
+ } else {
6554
6547
rc = - EEXIST ;
6555
6548
ksmbd_debug (SMB , "link already exists\n" );
6556
6549
goto out ;
6557
6550
}
6551
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION (6 , 4 , 0 )
6552
+ ksmbd_vfs_kern_path_unlock (& parent_path , & path );
6553
+ #endif
6558
6554
}
6559
-
6560
6555
rc = ksmbd_vfs_link (work , target_name , link_name );
6561
6556
if (rc )
6562
6557
rc = - EINVAL ;
6563
6558
out :
6564
- #if LINUX_VERSION_CODE >= KERNEL_VERSION (6 , 4 , 0 )
6565
- if (file_present )
6566
- ksmbd_vfs_kern_path_unlock (& parent_path , & path );
6567
- #endif
6559
+
6568
6560
if (!IS_ERR (link_name ))
6569
6561
kfree (link_name );
6570
6562
kfree (pathname );
0 commit comments