Received: by 2002:a05:7412:8d06:b0:f9:332d:97f1 with SMTP id bj6csp21561rdb; Mon, 18 Dec 2023 07:56:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IHmHFZhpcf51POcGFEexaObzrRK87j1j8XUU0KbxNgpwVFBm5itfnvOO9nm0aptezAp1lxR X-Received: by 2002:a05:6a20:9390:b0:18f:c737:1c9f with SMTP id x16-20020a056a20939000b0018fc7371c9fmr20508610pzh.5.1702914976060; Mon, 18 Dec 2023 07:56:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702914976; cv=none; d=google.com; s=arc-20160816; b=KAKC2dcEblAbQ1BaxlEz/BETZnsUyEs5r+KFR7HPHPDLU8GbkXryihXW8I6ixJ1pnv Hxoid4w51l5nPmMtE/R655WZ2lUMUaNyixmmDAxjDo9vlIIwHqpmDAzQrNJl4SFqMFgG Aip7RFHDe+tFRs+lIwsUYvxzZz2lLV4qCi1F5KtMvGUcE8pC3QeHWu3OIdaAbUpWA0GT yu3Vm72B77E8BOchYvN4fZ6C0VNMR1DxfpyzrdxHOCiYm/qvvJZMXM210udwi5AxFacF etG6wenQl9SM59YLuaoVlHhNqaPRrlpI/P6UOY4zlXsptD5Oho9xtEWvqLa9mYmKfUb2 tK0Q== 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:dkim-signature:dkim-signature :dkim-signature:dkim-signature; bh=MJ9W11dpS2QdHFN8Mkp+AZQ70TUdu4la3PZucmekhPg=; fh=3QIVKsEmsld8rvcEkMSr/XDw53o2lrGJeYcvS7FhzFk=; b=tCs5FTfnZhAsCunodSwqFgJfYAF1oq4ZFWCs/WUeCs1FEV4rY1LmGg5TRVGb8d9JEM IUbAA4jexkxHtiu+YNahvvbDi5UQSJ5MfywJLzzhR4szB3nucUcNmrYFuRw3EREMLg0m z0FuO0hgHTha+Hz48Y2rgZ1bgKPSz3zLGTml+0/1X/loRFHaixR+PWeDnHJK71H7Ryzd PrlOAQiQsAzlV+mJ/rUTpN2Qups+Gk94GMXemXz+Xw3FI4Afr7lN/D1oVptaN2fpXAG6 5L+tv+XOPz+bYMZYKColXXtT6rbae9C9YDMgN3V6iCwFQUq1tAwmyu95CfeG+AlxpLb2 FNng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=IvMCQetk; dkim=neutral (no key) header.i=@suse.de; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=IvMCQetk; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-kernel+bounces-3991-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3991-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id z4-20020a656104000000b005c6bd30ed60si18033932pgu.6.2023.12.18.07.56.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 07:56:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-3991-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=IvMCQetk; dkim=neutral (no key) header.i=@suse.de; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=IvMCQetk; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-kernel+bounces-3991-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3991-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (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 sv.mirrors.kernel.org (Postfix) with ESMTPS id B6E9F28142A for ; Mon, 18 Dec 2023 15:56:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EC01A3D540; Mon, 18 Dec 2023 15:56:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="IvMCQetk"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="lDuwQufK"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="IvMCQetk"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="lDuwQufK" 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 E338C1EA71 for ; Mon, 18 Dec 2023 15:56:07 +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 [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 1B3C71FD49; Mon, 18 Dec 2023 15:56:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1702914966; h=from:from:reply-to: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=MJ9W11dpS2QdHFN8Mkp+AZQ70TUdu4la3PZucmekhPg=; b=IvMCQetkPEO5Dzkze/zc4aOeAn6Dhn/CB0+bTm2N7DAq0YHW5eYbmw4QohuYp7d8m4WlwT ZTcCFzRLkrFi4PVjKxN9o1V7fjA+plcDZu+S/sc4od2mI1ij8UeF1ONeuEe9amZb5ApZmE O1FlSxZN6H4yJUKs0iBbbrsYTKVGcJA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1702914966; h=from:from:reply-to: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=MJ9W11dpS2QdHFN8Mkp+AZQ70TUdu4la3PZucmekhPg=; b=lDuwQufKhNUx5cp6whAEwIvUvrqo9olKG3fcGEx/kmLETuO5egagr+66pCmauXwr4LuNtb KoNxH7JrdVVqExDw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1702914966; h=from:from:reply-to: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=MJ9W11dpS2QdHFN8Mkp+AZQ70TUdu4la3PZucmekhPg=; b=IvMCQetkPEO5Dzkze/zc4aOeAn6Dhn/CB0+bTm2N7DAq0YHW5eYbmw4QohuYp7d8m4WlwT ZTcCFzRLkrFi4PVjKxN9o1V7fjA+plcDZu+S/sc4od2mI1ij8UeF1ONeuEe9amZb5ApZmE O1FlSxZN6H4yJUKs0iBbbrsYTKVGcJA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1702914966; h=from:from:reply-to: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=MJ9W11dpS2QdHFN8Mkp+AZQ70TUdu4la3PZucmekhPg=; b=lDuwQufKhNUx5cp6whAEwIvUvrqo9olKG3fcGEx/kmLETuO5egagr+66pCmauXwr4LuNtb KoNxH7JrdVVqExDw== 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 09D4F13BC8; Mon, 18 Dec 2023 15:56:06 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id PlYvAZZrgGVXAgAAn2gu4w (envelope-from ); Mon, 18 Dec 2023 15:56:06 +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 10/16] nvmet-fc: hold reference on hostport match Date: Mon, 18 Dec 2023 16:30:58 +0100 Message-ID: <20231218153105.12717-11-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-Spam-Level: X-Spamd-Result: default: False [0.90 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; REPLY(-4.00)[]; BROKEN_CONTENT_TYPE(1.50)[]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_SEVEN(0.00)[8]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-0.00)[26.58%] Authentication-Results: smtp-out2.suse.de; none X-Spam-Score: 0.90 X-Spam-Flag: NO The hostport data structure is shared between the association, this why we keep track of the users via a refcount. So we should not decrement the refcount on a match and free the hostport several times. Reported by KASAN. Signed-off-by: Daniel Wagner --- drivers/nvme/target/fc.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c index 0adf65154e27..fa7a6d2edd88 100644 --- a/drivers/nvme/target/fc.c +++ b/drivers/nvme/target/fc.c @@ -1070,8 +1070,6 @@ nvmet_fc_alloc_hostport(struct nvmet_fc_tgtport *tgtport, void *hosthandle) /* new allocation not needed */ kfree(newhost); newhost = match; - /* no new allocation - release reference */ - nvmet_fc_tgtport_put(tgtport); } else { newhost->tgtport = tgtport; newhost->hosthandle = hosthandle; -- 2.43.0