Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9086826pxu; Mon, 28 Dec 2020 06:18:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJw1YkwksxhvsN3okzl15zwRh0JpPqRZTmxsymVinkADv+Gm0xKx19aDV6BanO1wjRos24i5 X-Received: by 2002:a17:907:c10:: with SMTP id ga16mr41671580ejc.43.1609165122804; Mon, 28 Dec 2020 06:18:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609165122; cv=none; d=google.com; s=arc-20160816; b=VhTddGO4vCo6WkS+8Y7g0WDl+gX5QZ/A2Zfv719EGG3tHp3+FqczmufzNW8Qsk0NGz Z2nGaiDqGnACTn1Q/ugpGraUJwCcX4MbwdCNGpU+udxDOyn9J9WRK7svu4V9duBv6Stv LWDBLQ0i1mn1Il5M6TmTInKc3fthmBhX97O0PdFr/mmikP6M2MoNR23AVnRfiqdx8BwV HB+PIB9Xsvigr4K2+F/ATJ72kUlHjKtDNH/gyRS/pS6gf+M/l1URnMSocdVuZwqoA2VY O4cNc4W631/zuDg4QNon+uiQoUUrWXbw5qlSwQcEgPirm3FOmySauPfm0WrwpBrYKxv3 4qRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=oNXpyDDEMTvCMXzHABWWNeuqPDTkVRpetKWtg1evsm8=; b=C0dNRuKeltRw5S32NLBXCWwPdyFJbDQvrrYOlFD6WHevsHDjVtuFK5ec/K7dYXhdDc obrAYmVGqjD9onF7RPkGxhN0PZMWuqcUUO/hYr0TuNf5gmoCPtiH9TYb9HhUi7MtkeAd rtYkJLf5716W/0wB9KVv6oUxsLgwdXNRvTQ532v0nZg/Y6oVaWT4JPW6LJL79wy1Ri9G Fik/ImutRFjxlsG+kmAEpgsPQu4dxfLvtQSY7qs1FpK+gwjBPnXE79CKRQRaoxMez3VQ wY8arv/r8Sl7XOaUDuT9c2H++znqkTB36iBMPsNtthldsbTKambKrsfRpT3goKB6Ez+0 M5Xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MO1yxwdL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dm25si19275275edb.109.2020.12.28.06.18.19; Mon, 28 Dec 2020 06:18:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MO1yxwdL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2441250AbgL1OQr (ORCPT + 99 others); Mon, 28 Dec 2020 09:16:47 -0500 Received: from mail.kernel.org ([198.145.29.99]:50956 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2440891AbgL1OQI (ORCPT ); Mon, 28 Dec 2020 09:16:08 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 25BAE229C6; Mon, 28 Dec 2020 14:15:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609164952; bh=vikSt3Bw0mkI1ByoomZ68YX/U833cSLaAk6T2rIPBjw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MO1yxwdLe3ZeTibjhT136uMEaJaCXR1+B2Q1x86PcGzSFCcjvyCIPbz6jEFR9CzLg GgoPQneKnQGkAt2FrzBgLdQswQCJJY/UXvOrgrWll5BYto94dOa1JSpWMG8btZ86JN aY4Ban8VwNPtMAQXwA4SVlBNxPFZwOzh8AxoDcw0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , Mike Christie , Qinglang Miao , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.10 358/717] scsi: iscsi: Fix inappropriate use of put_device() Date: Mon, 28 Dec 2020 13:45:56 +0100 Message-Id: <20201228125038.163858685@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Qinglang Miao [ Upstream commit 6dc1c7ab6f047f45b62986ffebc5324e86ed5f5a ] kfree(conn) is called inside put_device(&conn->dev) which could lead to use-after-free. In addition, device_unregister() should be used here rather than put_deviceO(). Link: https://lore.kernel.org/r/20201120074852.31658-1-miaoqinglang@huawei.com Fixes: f3c893e3dbb5 ("scsi: iscsi: Fail session and connection on transport registration failure") Reported-by: Hulk Robot Reviewed-by: Mike Christie Signed-off-by: Qinglang Miao Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/scsi_transport_iscsi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c index 2eb3e4f9375a5..2e68c0a876986 100644 --- a/drivers/scsi/scsi_transport_iscsi.c +++ b/drivers/scsi/scsi_transport_iscsi.c @@ -2313,7 +2313,9 @@ iscsi_create_conn(struct iscsi_cls_session *session, int dd_size, uint32_t cid) return conn; release_conn_ref: - put_device(&conn->dev); + device_unregister(&conn->dev); + put_device(&session->dev); + return NULL; release_parent_ref: put_device(&session->dev); free_conn: -- 2.27.0