From nobody Wed Dec 24 08:07:01 2025 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 565BF679FF for ; Tue, 30 Jan 2024 09:49:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706608196; cv=none; b=XY/rSwVkiH10EazlLGPBJq8PFp638eDqIHX0UGqtc1uYtBXulmY3mgMGPXrT0uWcN40ivxfsxG/SczR0BpQmt75F2+xUCO9jG6GnRVmy+YfS+qAaBfvyRI0/5FK/8HZeWGIPAmkI2xjDU0pBQRAaC3pHH2pP8SjtBTW9vZmQ4oo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706608196; c=relaxed/simple; bh=CHEe3BgyB5vNBsrIi37+8+stLpieh300FXdpijsIshU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=h5KRCNhTMwu/005J70/JzPCgB4VhvzYNcRhZLrmdhOmrdPA3UsGzjPNEZdAlqYlu200DpR5uVaVXpyCejy42ZWCe8R1dDZ17khwJ6gcUHF16BiecBQzeKVE/mZvG55E8yxrpYNS8E4NyYMA7E7jyPWYJh/DF4m2G9XZXfZGjj0g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:98]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id A3F601F842; Tue, 30 Jan 2024 09:49:53 +0000 (UTC) Received: from imap2.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id 9155E13462; Tue, 30 Jan 2024 09:49:53 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id X/UIIkHGuGWZbwAAn2gu4w (envelope-from ); Tue, 30 Jan 2024 09:49:53 +0000 From: Daniel Wagner To: James Smart Cc: Keith Busch , Christoph Hellwig , Hannes Reinecke , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Daniel Wagner Subject: [PATCH v4 09/12] nvmet-fc: abort command when there is no binding Date: Tue, 30 Jan 2024 10:49:35 +0100 Message-ID: <20240130094938.1575-10-dwagner@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240130094938.1575-1-dwagner@suse.de> References: <20240130094938.1575-1-dwagner@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Level: Authentication-Results: smtp-out2.suse.de; none X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Spam-Score: -4.00 X-Rspamd-Queue-Id: A3F601F842 X-Spam-Flag: NO Content-Type: text/plain; charset="utf-8" When the target port has not active port binding, there is no point in trying to process the command as it has to fail anyway. Instead adding checks to all commands abort the command early. Reviewed-by: Hannes Reinecke Signed-off-by: Daniel Wagner Reviewed-by: Christoph Hellwig --- drivers/nvme/target/fc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c index fe3246024836..c80b8a066fd1 100644 --- a/drivers/nvme/target/fc.c +++ b/drivers/nvme/target/fc.c @@ -1099,6 +1099,9 @@ nvmet_fc_alloc_target_assoc(struct nvmet_fc_tgtport *= tgtport, void *hosthandle) int idx; bool needrandom =3D true; =20 + if (!tgtport->pe) + return NULL; + assoc =3D kzalloc(sizeof(*assoc), GFP_KERNEL); if (!assoc) return NULL; @@ -2514,8 +2517,9 @@ nvmet_fc_handle_fcp_rqst(struct nvmet_fc_tgtport *tgt= port, =20 fod->req.cmd =3D &fod->cmdiubuf.sqe; fod->req.cqe =3D &fod->rspiubuf.cqe; - if (tgtport->pe) - fod->req.port =3D tgtport->pe->port; + if (!tgtport->pe) + goto transport_error; + fod->req.port =3D tgtport->pe->port; =20 /* clear any response payload */ memset(&fod->rspiubuf, 0, sizeof(fod->rspiubuf)); --=20 2.43.0