diff mbox series

cifs: Avoid error pointer dereference

Message ID 20201218092949.1767-1-scabrero@suse.de (mailing list archive)
State New, archived
Headers show
Series cifs: Avoid error pointer dereference | expand

Commit Message

Samuel Cabrero Dec. 18, 2020, 9:29 a.m. UTC
The patch 7d6535b72042: "cifs: Simplify reconnect code when dfs
upcall is enabled" leads to the following static checker warning:

	fs/cifs/connect.c:160 reconn_set_next_dfs_target()
	error: 'server->hostname' dereferencing possible ERR_PTR()

Avoid dereferencing the error pointer by early returning on error
condition.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Samuel Cabrero <scabrero@suse.de>
---
 fs/cifs/connect.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Steve French Dec. 18, 2020, 1:45 p.m. UTC | #1
tentatively merged into cifs-2.6.git for-next pending more testing

On Fri, Dec 18, 2020 at 3:48 AM Samuel Cabrero <scabrero@suse.de> wrote:
>
> The patch 7d6535b72042: "cifs: Simplify reconnect code when dfs
> upcall is enabled" leads to the following static checker warning:
>
>         fs/cifs/connect.c:160 reconn_set_next_dfs_target()
>         error: 'server->hostname' dereferencing possible ERR_PTR()
>
> Avoid dereferencing the error pointer by early returning on error
> condition.
>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Samuel Cabrero <scabrero@suse.de>
> ---
>  fs/cifs/connect.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
> index 509a41ff56b8..b9df85506938 100644
> --- a/fs/cifs/connect.c
> +++ b/fs/cifs/connect.c
> @@ -155,6 +155,7 @@ static void reconn_set_next_dfs_target(struct TCP_Server_Info *server,
>                 cifs_dbg(FYI,
>                          "%s: failed to extract hostname from target: %ld\n",
>                          __func__, PTR_ERR(server->hostname));
> +               return;
>         }
>
>         rc = reconn_set_ipaddr_from_hostname(server);
> --
> 2.29.2
>
diff mbox series

Patch

diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 509a41ff56b8..b9df85506938 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -155,6 +155,7 @@  static void reconn_set_next_dfs_target(struct TCP_Server_Info *server,
 		cifs_dbg(FYI,
 			 "%s: failed to extract hostname from target: %ld\n",
 			 __func__, PTR_ERR(server->hostname));
+		return;
 	}
 
 	rc = reconn_set_ipaddr_from_hostname(server);