From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) (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 2D30641A565 for ; Wed, 12 Aug 2026 10:59:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786532389; cv=none; b=W+qu/facuybFLhejJDaDFxtNICX03syFT/9VKylbAJp1ORMPe/U0fU4/fxX9n28xSWLfNVPkH+67XNln9OyGJ6AcfzGv62RwytQLhEznKsXW2jzGuPDICUV/Stn/hsZ16oKO5qAvkXXu++xSvez8heGq5+gVR8dVmBD5+zDnI80= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786532389; c=relaxed/simple; bh=2o1eyljTRdeWeibAzaPwvsCtq+lmY/s64UExAH5FNNk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CJyFU9VK0SoSzQvjr/xmflF81CxB+uLnUFCYPsk/xZkyiPa3sMixVvJ40iK9EE/SKzJTWILspE8q/bzJAqZhma1HE8yk+JFwhrlCS+7YHh9lWQDdoh7CIEYUC3bQLoTJaqWXgia+aIZdzH+0RnoXOqY2Nmdy9T5BWDpGHHZ25so= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=JYT85gJD; arc=none smtp.client-ip=209.85.216.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JYT85gJD" Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-381b831d535so1381489a91.0 for ; Wed, 12 Aug 2026 03:59:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786532387; x=1787137187; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=ZEyXLqcxbr/SLsSUNviv8nzjhBE4ozvJHxIITTWu9ww=; b=JYT85gJDjEeaQ+x9YD4AOpsb6qEtgILNevE7thlz3utSmS9vCRn/SQoN2M+eRcRXd7 NPme4Uzc0oVrZ7jaf+/s4rn49Ud0/S4hQ1pwloJmj7XMwjyvIo7kEgDLpRQKgAawqmry QTc0BhNvO1hmudiFWtjRC1mBJwI0u8tVsW3G/DFD49c5UQCX6nDNY1bgBowcWxFgVGFc dmrGup3bk7eE6Vg4VI8cRZvH6ETkFdbLFDcQDUhduEfrh6eQ7Oz6bud6XMA06kXSQgz8 6+plM9t96tpOLlFDvUFJpke7729rOLb1eJ6coXjJwIMtKH9d2jY8pcKQ5lOxfynHnUUP 0UiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786532387; x=1787137187; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=ZEyXLqcxbr/SLsSUNviv8nzjhBE4ozvJHxIITTWu9ww=; b=Ao4ZGzlAiRzkDiRRJxM/ijKfD39/lUc0YU0Q6Bcr/Q2UL7AY4W8XTQXRBfHgtuiaaw W4joNp1UpVTgUwU7ISFBAcpbExiHkTaVeVTOG3ALVoSpzVeaFeMTXsl2RThya0eiZVVY Hp5f3lwaCrOdC13L3ZpkDNl3UTEUFIGUEoKlvqe1FQdU8RCWKihCS9Jc8VRTf/II4t77 P5Mlo+FVm8vgBFOgnm2bL1cFpd/Z9L8vT1ztWRWee/RYCo7oacgcnm5Viy72p3AyifPY P7Rcc9JSlOPh4PcI4JN4yhdGbBdflyEggmo5hesWlU57ouzMvaYT0P6Wy3qRtH61d3hv pqIQ== X-Forwarded-Encrypted: i=1; AHgh+RpX505OygOWbKYEXJNKRmLDrQgePsevLshf/cM9IRuViatCoZdgmrbkTeNk1aKr9F1XZ00OdNmyICtoDuc=@vger.kernel.org X-Gm-Message-State: AOJu0YyQTYfIPvlFZgSsdfYQ3RnjodqIbWCa19+ImcmzyX9egJvCuUW7 y4E2UAp9qp05Aic0Z7JNHaUMCgTm5xz3XREiHsEz7JJbZzpU2XWnaQiR X-Gm-Gg: AR+sD11+XGb1tDqbUDjsZDyGb+JsxMXu9t3n9nDGUzV0smI2c2eqi2h3bDduEC6JMLK 34DnDYSPzlqC4LVZTcx8JIrAiRwWbKc4lvVlqhYrjlknOmRpcwPVdIuMNsxyPpzExtnIgtAmAx5 y3i8IxQU9BrB4RxtkAH8h5qbcOe7A148tT03m+RUdeKeGmlseq7DHfRAmDhkQ6mMEgndv+8Npfz JVyrVL3/DQhxkqrjitgzMGDTZV3is3BFfeMZBtL1ZVlxDIuVDXTmWSG+UNtiW+iwbMUibgzTT6f /YrCmF+WDzGdk8z5H/DfaNZ/nxESqboH8iLnixnAcpmF7E3Pxk1qB+uzGitIHfYk3kxV5Z6Fhob p5mbXi8tlv+mv8nZBRGyk8CLto5VWSyAJ6gxLsZdNFE/XTzQ/MMLmjedZjtdrw5CyICs2jLIR8R tIMPcK0UTbrfEM31E2DkRdE30qY0UCkRMrPcVUBAe5kaxLSteVmtxSyiA8lEephNi3D25zg/8= X-Received: by 2002:a17:90b:398c:b0:381:792d:f993 with SMTP id 98e67ed59e1d1-3930146a70dmr4046826a91.17.1786532387416; Wed, 12 Aug 2026 03:59:47 -0700 (PDT) Received: from ubuntu.. ([219.241.133.184]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-392fe55a7desm966989a91.4.2026.08.12.03.59.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Aug 2026 03:59:46 -0700 (PDT) From: Rihyeon Kim To: cassel@kernel.org Cc: kbusch@kernel.org, hch@lst.de, sagi@grimberg.me, axboe@kernel.dk, justin.tee@broadcom.com, nareshgottumukkala83@gmail.com, paul.ely@broadcom.com, kch@nvidia.com, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] nvme-fc: fix double free of fabrics options when nvme_add_ctrl() fails Date: Wed, 12 Aug 2026 19:59:41 +0900 Message-ID: <20260812105941.55577-1-rihyeon8648@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Hello, Thanks for the suggestion. > Wouldn't a nicer fix be to change nvme_fc_ctrl_free() to look more like > nvme_tcp_ctrl_free(), i.e. something like: > > + if (list_empty(&ctrl->ctrl_list)) > + goto free_ctrl; I am not sure whether that would work, and I may well be missing something. From what I could tell, nvme_tcp_create_ctrl() does its list_add_tail() last, while nvme_fc_init_ctrl() does it before the nvme_change_ctrl_state() and queue_delayed_work() checks, so on those two failure paths the controller is already on the list and opts would end up freed twice again. The early goto would also skip the ida_free(), put_device() and nvme_fc_rport_put() for what nvme_fc_alloc_ctrl() takes before the list_add. I am not familiar with this driver either, so please correct me if I have misread it. Keith suggested moving the existing clear from fail_ctrl: down to out_put_ctrl: instead, so I will send that as v2. Thanks, Rihyeon