Commit f0b6a834 authored by Paulo Alcantara's avatar Paulo Alcantara Committed by Steve French

smb: client: fix warning in generic_ip_connect()

This fixes the following warning reported by kernel test robot

  fs/smb/client/connect.c:2974 generic_ip_connect() error: we
  previously assumed 'socket' could be null (see line 2962)

Link: https://lore.kernel.org/all/202306170124.CtQqzf0I-lkp@intel.com/Signed-off-by: default avatarPaulo Alcantara (SUSE) <pc@manguebit.com>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent 215533f8
...@@ -2934,11 +2934,11 @@ ip_rfc1001_connect(struct TCP_Server_Info *server) ...@@ -2934,11 +2934,11 @@ ip_rfc1001_connect(struct TCP_Server_Info *server)
static int static int
generic_ip_connect(struct TCP_Server_Info *server) generic_ip_connect(struct TCP_Server_Info *server)
{ {
int rc = 0;
__be16 sport;
int slen, sfamily;
struct socket *socket = server->ssocket;
struct sockaddr *saddr; struct sockaddr *saddr;
struct socket *socket;
int slen, sfamily;
__be16 sport;
int rc = 0;
saddr = (struct sockaddr *) &server->dstaddr; saddr = (struct sockaddr *) &server->dstaddr;
...@@ -2960,18 +2960,19 @@ generic_ip_connect(struct TCP_Server_Info *server) ...@@ -2960,18 +2960,19 @@ generic_ip_connect(struct TCP_Server_Info *server)
ntohs(sport)); ntohs(sport));
} }
if (socket == NULL) { if (server->ssocket) {
socket = server->ssocket;
} else {
rc = __sock_create(cifs_net_ns(server), sfamily, SOCK_STREAM, rc = __sock_create(cifs_net_ns(server), sfamily, SOCK_STREAM,
IPPROTO_TCP, &socket, 1); IPPROTO_TCP, &server->ssocket, 1);
if (rc < 0) { if (rc < 0) {
cifs_server_dbg(VFS, "Error %d creating socket\n", rc); cifs_server_dbg(VFS, "Error %d creating socket\n", rc);
server->ssocket = NULL;
return rc; return rc;
} }
/* BB other socket options to set KEEPALIVE, NODELAY? */ /* BB other socket options to set KEEPALIVE, NODELAY? */
cifs_dbg(FYI, "Socket created\n"); cifs_dbg(FYI, "Socket created\n");
server->ssocket = socket; socket = server->ssocket;
socket->sk->sk_allocation = GFP_NOFS; socket->sk->sk_allocation = GFP_NOFS;
socket->sk->sk_use_task_frag = false; socket->sk->sk_use_task_frag = false;
if (sfamily == AF_INET6) if (sfamily == AF_INET6)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment