[PATCH 3/4][groovy:linux] cifs: Avoid error pointer dereference

Tim Gardner tim.gardner at canonical.com
Thu Jun 17 17:36:44 UTC 2021

From: Samuel Cabrero <scabrero at suse.de>

BugLink: https://bugs.launchpad.net/bugs/1929831

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

Reported-by: Dan Carpenter <dan.carpenter at oracle.com>
Signed-off-by: Samuel Cabrero <scabrero at suse.de>
Signed-off-by: Steve French <stfrench at microsoft.com>
(cherry picked from commit 0bf1bafb17df03fbd0e8b9a086c39e6f24af7193)
Signed-off-by: Tim Gardner <tim.gardner at canonical.com>
 fs/cifs/connect.c | 1 +
 1 file changed, 1 insertion(+)

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

More information about the kernel-team mailing list