From patchwork Wed Jan 31 08:51:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 194622 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1761749dyb; Wed, 31 Jan 2024 01:08:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IHlHuZq8wJaF9gneeK9xNHQhi3pL0DsMOw3BEpW6u2/1NFsQiawt9EwxdJi1PQ2Cuwb4zQS X-Received: by 2002:a17:906:488:b0:a30:3b5b:ea5b with SMTP id f8-20020a170906048800b00a303b5bea5bmr614767eja.56.1706692122344; Wed, 31 Jan 2024 01:08:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706692122; cv=pass; d=google.com; s=arc-20160816; b=gry9ZdcCD5Z6b6ZwQBltVG+ykC30PWDiU001oJV191lC6/fa5j/5mtRykJnr0DMz6H 3Cxq0GqOe06aGrRhbt/eKGAbMgEDEZ5qmNCsbaNrIIr0vdGsqfPvYIwjybH9QxHV40lV 7/1yXZFtvaGVwTwb6byhdJDCTKdR0/GciW5kR/4fTecriwKT8lwsyNvh3OgRRkr2+kUX 77wg5NF/C6RkdLfZ5YstTa770lYISau9vc5Dyuhx2iD/mnXjSPDx0Oys3pJNpVv3c5hF Ej5hsq3KRRCVJAWt+SqzVqc67G8/MQBk/a8hgGh+o2Z9YVVgFdD/08+6YvpMSShoemnT Ivyg== ARC-Message-Signature: i=2; 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=tV2MGThNuULDTIR8ZdlJrRAXWk+1WOpSUxslfvlmMOI=; fh=m6PAHX1P86Nn3goDEzLSoduf2BZyKUIfc2+ENsrsy20=; b=g5ZJwvO/r1qNzG+uQesHr4MhBEEudL1fNQPHdbnCEM3Mu7matH/NvtzvreUdVqlfO/ /mlMH/a4mXVxdoHIprL77W/QhZRY9BqN1ZtdpcWhRl1s1x8tLb6Wz3l9BxkxCxdbRqRr VN7PhUdkfHSGFnbyaJGge2gAuPZAMfCurbFw6WqkpEfygL+36GL5LAwQkTlBgZAOeHNY MUNe85bOtXiKHtaFNjzFKQQPrbfDcty9dUtiyPi23IWbJkuPhBKR8oDsWalze+cdEyYk dFgQ7h62GIuwf0BVMnQHiYUAhXZ59UiQs93arp4HEMER2J3IhXLP80eR56FR6UhDpsLs z2lQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=R3sJXBOi; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=V+pZwvh3; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=R3sJXBOi; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=V+pZwvh3; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-46073-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46073-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de X-Forwarded-Encrypted: i=1; AJvYcCUim53Nji4ICqK5tB3Euy2jP5X0+SvjmMyVBq9ilS+A0XVz3hnpFMNh244DtP0CQ6yLrLWnHauZoqnU1gRT08TWn+BB+g== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id o15-20020a17090611cf00b00a3070ebd737si5295774eja.485.2024.01.31.01.08.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 01:08:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46073-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=R3sJXBOi; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=V+pZwvh3; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=R3sJXBOi; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=V+pZwvh3; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-46073-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46073-ouuuleilei=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 2882D1F2EE42 for ; Wed, 31 Jan 2024 09:01:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 977077AE4A; Wed, 31 Jan 2024 08:51:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="R3sJXBOi"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="V+pZwvh3"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="R3sJXBOi"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="V+pZwvh3" 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 D9BBA79DA6 for ; Wed, 31 Jan 2024 08:51:26 +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=1706691088; cv=none; b=Xq2ZupDnmp9jSoK2YEUM4vm3CMGyway6oLN8TzAXtO6xeJYkiU6gOgcwUZLe/yn3qUspUJkloAXrc/AoWO5ybrl5tb5PpiGWIv8Hlf2p4PObbGfIn6lo8ntq5gGrz2sjKlnN8ucDbb8aZxJ19lq6jWLCUvxpLXhm+GC7JTyNIIw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706691088; c=relaxed/simple; bh=k9VnTC2E0scTt27fHWfaedyxUc7y3ETys0MXODD+4u0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aGhUB4j1l1ix3/sTjvO2ECvbVsVs1aS6Eldm3zjSQPc5J8Ngp4aqsZQgxKX/ygF/f5Lffl603/dCyxSEs6irfaPykK60cfTioFbaX/ewF02bPS6vX9v9BSjZK1XqFWG+6n4s7392JIpysbomrlo5UrnsYxW6qXwJCl1fpESVEnI= 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; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=R3sJXBOi; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=V+pZwvh3; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=R3sJXBOi; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=V+pZwvh3; 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 [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 2034C1FD0E; Wed, 31 Jan 2024 08:51:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706691085; 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=tV2MGThNuULDTIR8ZdlJrRAXWk+1WOpSUxslfvlmMOI=; b=R3sJXBOiHBdZXbXSqNVxZB+e5d2RasvE5TymeW1cne1QpwY8ZtD+8DtnBciUjjlYWairjf ionBbRwwlyemK8Ge/yjYgUz+JHFIHT3qWscgsk2rna5LEwf6g85qQi9zHwvwez6w3OJshc Aj9TgWsm1qxbVxf7pHcROpX3WJb7hx8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706691085; 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=tV2MGThNuULDTIR8ZdlJrRAXWk+1WOpSUxslfvlmMOI=; b=V+pZwvh39BnHJhGktSGfTLqpXdVzh3EJ73gPPUiHQqz8Wvzyki4iKdBNlPr3ma9xAVEKmU WUREzTA7HCp826Dg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706691085; 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=tV2MGThNuULDTIR8ZdlJrRAXWk+1WOpSUxslfvlmMOI=; b=R3sJXBOiHBdZXbXSqNVxZB+e5d2RasvE5TymeW1cne1QpwY8ZtD+8DtnBciUjjlYWairjf ionBbRwwlyemK8Ge/yjYgUz+JHFIHT3qWscgsk2rna5LEwf6g85qQi9zHwvwez6w3OJshc Aj9TgWsm1qxbVxf7pHcROpX3WJb7hx8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706691085; 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=tV2MGThNuULDTIR8ZdlJrRAXWk+1WOpSUxslfvlmMOI=; b=V+pZwvh39BnHJhGktSGfTLqpXdVzh3EJ73gPPUiHQqz8Wvzyki4iKdBNlPr3ma9xAVEKmU WUREzTA7HCp826Dg== 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 0E7EC132FA; Wed, 31 Jan 2024 08:51:25 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id KFIYAg0KumWOHAAAn2gu4w (envelope-from ); Wed, 31 Jan 2024 08:51:25 +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 v5 06/12] nvmet-fc: hold reference on hostport match Date: Wed, 31 Jan 2024 09:51:06 +0100 Message-ID: <20240131085112.21668-7-dwagner@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240131085112.21668-1-dwagner@suse.de> References: <20240131085112.21668-1-dwagner@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Authentication-Results: smtp-out2.suse.de; none X-Spamd-Result: default: False [2.27 / 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]; 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)[7]; 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(-2.63)[98.35%] X-Spam-Level: ** X-Spam-Score: 2.27 X-Spam-Flag: NO X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789596398948422975 X-GMAIL-MSGID: 1789596398948422975 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. Reviewed-by: Hannes Reinecke Reviewed-by: Christoph Hellwig 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 b44b99525c44..205a12b1e841 100644 --- a/drivers/nvme/target/fc.c +++ b/drivers/nvme/target/fc.c @@ -1068,8 +1068,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;