From patchwork Mon Jul 6 18:16:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Alcantara X-Patchwork-Id: 11646425 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C1D3F1398 for ; Mon, 6 Jul 2020 18:16:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A0DAC206E9 for ; Mon, 6 Jul 2020 18:16:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=cjr.nz header.i=@cjr.nz header.b="ptghoURC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729622AbgGFSQp (ORCPT ); Mon, 6 Jul 2020 14:16:45 -0400 Received: from mx.cjr.nz ([51.158.111.142]:20746 "EHLO mx.cjr.nz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729698AbgGFSQp (ORCPT ); Mon, 6 Jul 2020 14:16:45 -0400 Received: from authenticated-user (mx.cjr.nz [51.158.111.142]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: pc) by mx.cjr.nz (Postfix) with ESMTPSA id 4CE887FD17; Mon, 6 Jul 2020 18:16:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cjr.nz; s=dkim; t=1594059403; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=blMYlrOkYAYQWl7wL9NKhsGrGo/q0IEcVRrc8WjrDY8=; b=ptghoURCMd8eSEQoIsT9JYgHe8NcQb0TQef/aCH0ps6RoMgoOy0OB8rE+w3xXvSNxVVChg 6wGZ96eV+Vi5d6f6JBLZwFs9Xw53n2Gamh1DSqr7DACzOOqCWTteZrfLUIED6nXH5/LERT vSHwWUbYV46jVSrFbGFXhmNg5b707+HlJSz1nn3WY2xxnSqolpqDm3N9hET9MN7HAc9TcP lbKBA+44iJj75DtZY2BkegVwBP19/s38MPxkhY79WpMifpQUqln1vbD/3QN6YE0VQiY3Tn ZS/9VJXtDC/lpyoc72vRaVi8sXGW7nPJfRtFneaPy5kYWf8t3faOIXBYUyHfRw== From: Paulo Alcantara To: linux-cifs@vger.kernel.org, smfrench@gmail.com Cc: Paulo Alcantara Subject: [PATCH v2 4/7] cifs: handle empty list of targets in cifs_reconnect() Date: Mon, 6 Jul 2020 15:16:06 -0300 Message-Id: <20200706181609.19480-5-pc@cjr.nz> In-Reply-To: <20200706181609.19480-1-pc@cjr.nz> References: <20200706181609.19480-1-pc@cjr.nz> MIME-Version: 1.0 Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org In case there were no cached DFS referrals in reconn_setup_dfs_targets(), set cifs_sb to NULL prior to calling reconn_set_next_dfs_target() so it would not try to access an empty tgt_list. Signed-off-by: Paulo Alcantara (SUSE) Reviewed-by: Aurelien Aptel --- fs/cifs/connect.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 9582f63b8ebc..1f35d84ed118 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -470,11 +470,13 @@ cifs_reconnect(struct TCP_Server_Info *server) sb = NULL; } else { cifs_sb = CIFS_SB(sb); - rc = reconn_setup_dfs_targets(cifs_sb, &tgt_list); - if (rc && (rc != -EOPNOTSUPP)) { - cifs_server_dbg(VFS, "%s: no target servers for DFS failover\n", - __func__); + if (rc) { + cifs_sb = NULL; + if (rc != -EOPNOTSUPP) { + cifs_server_dbg(VFS, "%s: no target servers for DFS failover\n", + __func__); + } } else { server->nr_targets = dfs_cache_get_nr_tgts(&tgt_list); }