[bug report] cifs: Simplify reconnect code when dfs upcall is enabled

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Samuel Cabrero,

The patch 7d6535b72042: "cifs: Simplify reconnect code when dfs
upcall is enabled" from Nov 30, 2020, leads to the following static
checker warning:

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

fs/cifs/connect.c
   128  static void reconn_set_next_dfs_target(struct TCP_Server_Info *server,
   129                                         struct cifs_sb_info *cifs_sb,
   130                                         struct dfs_cache_tgt_list *tgt_list,
   131                                         struct dfs_cache_tgt_iterator **tgt_it)
   132  {
   133          const char *name;
   134          int rc;
   135  
   136          if (!cifs_sb || !cifs_sb->origin_fullpath)
   137                  return;
   138  
   139          if (!*tgt_it) {
   140                  *tgt_it = dfs_cache_get_tgt_iterator(tgt_list);
   141          } else {
   142                  *tgt_it = dfs_cache_get_next_tgt(tgt_list, *tgt_it);
   143                  if (!*tgt_it)
   144                          *tgt_it = dfs_cache_get_tgt_iterator(tgt_list);
   145          }
   146  
   147          cifs_dbg(FYI, "%s: UNC: %s\n", __func__, cifs_sb->origin_fullpath);
   148  
   149          name = dfs_cache_get_tgt_name(*tgt_it);
   150  
   151          kfree(server->hostname);
   152  
   153          server->hostname = extract_hostname(name);
   154          if (IS_ERR(server->hostname)) {
                           ^^^^^^^^^^^^^^^^

   155                  cifs_dbg(FYI,
   156                           "%s: failed to extract hostname from target: %ld\n",
   157                           __func__, PTR_ERR(server->hostname));

This should probably just return here.  I don't totally understand why
this is a void function...

   158          }
   159  
   160          rc = reconn_set_ipaddr_from_hostname(server);
                                                     ^^^^^^
"server->hostname" is dereferenced inside the function.

   161          if (rc) {
   162                  cifs_dbg(FYI, "%s: failed to resolve hostname: %d\n",
   163                           __func__, rc);
   164          }
   165  }

regards,
dan carpenter



[Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux