Received: by 2002:a05:7412:8d06:b0:f9:332d:97f1 with SMTP id bj6csp34491rdb; Mon, 18 Dec 2023 08:13:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IGHf1OyGHFo/g4GWgdwQYlvwmtuYY5CUPCh6YJ601b446RG8c+0Kl76CzRLeVXIM2EGnw3m X-Received: by 2002:a17:907:9241:b0:a23:58af:81c4 with SMTP id kb1-20020a170907924100b00a2358af81c4mr887553ejb.39.1702915983850; Mon, 18 Dec 2023 08:13:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702915983; cv=none; d=google.com; s=arc-20160816; b=lMzgH2t5vQSCoVHZ7safZUxcYketAZCMliqPjwT6Pce50jruCTkoyiWfpSmgsPHTJB y8uoJZjZa+W8ctBYqFu2XEmyN6/nm/FA+SpS3t75I7mqmWODKSS3ZFv1sikmLHu8LdFz Yqrxc90Dx7/2+Gd1BfrAD4/MGoWxpHc9gApLRI1TUMqvv8Km+nLcxRGFx0sZrWyrUQgM VSMLb2dz5deNMo4QtpuZnhbs6xOuo9JMu6g5p4QL2qPmPufHcHglpMLJOWsPxJ75zKyN k0D0HQh624TrfoedOiElKJ5gQ+v4zh4TeKwqYw6jskArRImjL4AAYmXvljpViwHxN7Ay MyuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=mOtf+QZDvmrKDTXJ4FRCySwcKfTtKvHv8paQJexeOGI=; fh=3QIVKsEmsld8rvcEkMSr/XDw53o2lrGJeYcvS7FhzFk=; b=niF2E53X60YtYTy1B/a4NiRY74s74pTb8T9GxAIm+FzJCyAOLw69M4o1jbLPYrEz0z 9L/UoZhgANGZqTZmlkvZcDKJ4twPTs/pql3dZ4afUxsBwIAZ7iu/ljixFHyoOTzsfsbQ OXX/Ina6Cy0aHs4H57PBk5yeNXEWGDGZu7Kwgogjzwrkr7BV0KzbBQZIayroNLFxE2LX SDft3pMrbL5Ma46N6pMM5AJHXufnLbKT06t6QPTmqHwFReD2Z8jjnhQfOIUdKbqcmqHt XJwTDR53DuwSshSk032hDzwf59uiDVXmahjPct8jsUG1+c0guDAmfxEf7bl5HvM0AilD vq8g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-4026-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4026-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id f14-20020a170906048e00b00a233508bc85si1730007eja.848.2023.12.18.08.13.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 08:13:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-4026-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-4026-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4026-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 8C38D1F211AC for ; Mon, 18 Dec 2023 16:07:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 110A07608D; Mon, 18 Dec 2023 16:02:54 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org 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 425DF49897 for ; Mon, 18 Dec 2023 16:02:51 +0000 (UTC) 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 8145E1FD4D; Mon, 18 Dec 2023 16:02:50 +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 7349013BC8; Mon, 18 Dec 2023 16:02:50 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id WUMpGyptgGUABAAAn2gu4w (envelope-from ); Mon, 18 Dec 2023 16:02:50 +0000 From: Daniel Wagner To: linux-nvme@lists.infradead.org Cc: linux-kernel@vger.kernel.org, Christoph Hellwig , Sagi Grimberg , Keith Busch , James Smart , Hannes Reinecke , Daniel Wagner Subject: [PATCH v3 13/16] nvmet-fc: abort command if when there is binding Date: Mon, 18 Dec 2023 16:31:01 +0100 Message-ID: <20231218153105.12717-14-dwagner@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231218153105.12717-1-dwagner@suse.de> References: <20231218153105.12717-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: 8bit X-Spam-Level: X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Level: X-Spam-Flag: NO X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] Authentication-Results: smtp-out2.suse.de; none X-Spam-Score: -4.00 X-Rspamd-Queue-Id: 8145E1FD4D 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. Signed-off-by: Daniel Wagner --- 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 47cecc8c72b2..663c51c9fe53 100644 --- a/drivers/nvme/target/fc.c +++ b/drivers/nvme/target/fc.c @@ -1101,6 +1101,9 @@ nvmet_fc_alloc_target_assoc(struct nvmet_fc_tgtport *tgtport, void *hosthandle) int idx; bool needrandom = true; + if (!tgtport->pe) + return NULL; + assoc = kzalloc(sizeof(*assoc), GFP_KERNEL); if (!assoc) return NULL; @@ -2520,8 +2523,9 @@ nvmet_fc_handle_fcp_rqst(struct nvmet_fc_tgtport *tgtport, fod->req.cmd = &fod->cmdiubuf.sqe; fod->req.cqe = &fod->rspiubuf.cqe; - if (tgtport->pe) - fod->req.port = tgtport->pe->port; + if (!tgtport->pe) + goto transport_error; + fod->req.port = tgtport->pe->port; /* clear any response payload */ memset(&fod->rspiubuf, 0, sizeof(fod->rspiubuf)); -- 2.43.0