[PATCH] smb: client: Remove redundant check in smb2_is_path_accessible()

Ivan Abramov posted 1 patch 11 months ago
fs/smb/client/smb2ops.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] smb: client: Remove redundant check in smb2_is_path_accessible()
Posted by Ivan Abramov 11 months ago
There is an unnecessary NULL check of cifs_sb in smb2_is_path_accessible(),
since cifs_sb is dereferenced multiple times prior to it.

It seems that there is no need to introduce any NULL checks of cifs_sb, 
since arguments of smb2_is_path_accessible() are assumed to be non-NULL.

Therefore, this redundant check can be removed.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Ivan Abramov <i.abramov@mt-integration.ru>
---
 fs/smb/client/smb2ops.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c
index 4dd11eafb69d..6958825431af 100644
--- a/fs/smb/client/smb2ops.c
+++ b/fs/smb/client/smb2ops.c
@@ -969,7 +969,7 @@ smb2_is_path_accessible(const unsigned int xid, struct cifs_tcon *tcon,
 			if (islink)
 				rc = -EREMOTE;
 		}
-		if (rc == -EREMOTE && IS_ENABLED(CONFIG_CIFS_DFS_UPCALL) && cifs_sb &&
+		if (rc == -EREMOTE && IS_ENABLED(CONFIG_CIFS_DFS_UPCALL) &&
 		    (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_DFS))
 			rc = -EOPNOTSUPP;
 		goto out;
-- 
2.39.5
Re: [PATCH] smb: client: Remove redundant check in smb2_is_path_accessible()
Posted by Steve French 10 months, 3 weeks ago
merged both patches into cifs-2.6.git for-next pending additional testing

On Mon, Mar 10, 2025 at 9:05 AM Ivan Abramov
<i.abramov@mt-integration.ru> wrote:
>
> There is an unnecessary NULL check of cifs_sb in smb2_is_path_accessible(),
> since cifs_sb is dereferenced multiple times prior to it.
>
> It seems that there is no need to introduce any NULL checks of cifs_sb,
> since arguments of smb2_is_path_accessible() are assumed to be non-NULL.
>
> Therefore, this redundant check can be removed.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Signed-off-by: Ivan Abramov <i.abramov@mt-integration.ru>
> ---
>  fs/smb/client/smb2ops.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c
> index 4dd11eafb69d..6958825431af 100644
> --- a/fs/smb/client/smb2ops.c
> +++ b/fs/smb/client/smb2ops.c
> @@ -969,7 +969,7 @@ smb2_is_path_accessible(const unsigned int xid, struct cifs_tcon *tcon,
>                         if (islink)
>                                 rc = -EREMOTE;
>                 }
> -               if (rc == -EREMOTE && IS_ENABLED(CONFIG_CIFS_DFS_UPCALL) && cifs_sb &&
> +               if (rc == -EREMOTE && IS_ENABLED(CONFIG_CIFS_DFS_UPCALL) &&
>                     (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_DFS))
>                         rc = -EOPNOTSUPP;
>                 goto out;
> --
> 2.39.5
>
>


-- 
Thanks,

Steve