Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1072441pxb; Thu, 19 Nov 2020 23:46:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJwZgTDHTTmJdvfSfmNpxFc8dCyppqNxcZ+oueFOi3MfUsaNs4fZ1L/RUhpVElQ+sQMv8yY/ X-Received: by 2002:a17:906:c186:: with SMTP id g6mr30237155ejz.465.1605858372353; Thu, 19 Nov 2020 23:46:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605858372; cv=none; d=google.com; s=arc-20160816; b=0T9FoNnYDqhY21CHRGaZEMsQWH/Hf3aKxh4fh2c7qPoO3r2gQnlBZJORL2X+lwKI36 ZpNY+wZea3xC9h9YYVkAjvYrJVYW54Naeal1sqk0LCxM9yOrj57iiS+V6lJIqNpFYRz3 FWGwkU6B46ktHSvRYnftyD8g7iXvnpP9CsLsmNpZPMw3mJhpW5gIpnpEPuj6AIaMYiPW SZbvuqB2N2uyu7kCZFvSWML+Q7Q3aCzDjScPGr0sOeY02Y47WmjNs/1cEBLLp0amFzOb 40x7x3W93EtNSZcyd0yNi2uoY/LJVFi/mlyA03/si77IVCTvh3VGgrWwqRb1w44MzwZw fAcw== 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 :message-id:date:subject:cc:to:from; bh=ujnrEiWNYPfVQX5DQUBWilg0+WmlB62xN6DEjuOXx4s=; b=rCZN0H9R6HPFsJx2nZBjL1gVh6DRmzckFxAmvenThgE1ff1k7pZ3fkNsN5tLiYI7TM 0CYCjjvtq2IqXdLx/JxTsmtqBlh1Zbu5LD1GsEIA0z704GKPmXES1DxISMox6kcG7KgR drHNJenkDq/uZXlaKlB+A1wKyrSvKIgGxQeKaMmm1gZQ07ctvzeSDz0vPP7w3hVR5jjv jenmz2AtHKt9mC6dI3kiKnptdYefl6qNIYArj9WVvBGELM1CbdgdDqJ02y47L6xNZwlD leW3gPjmDb/BHIpeaJQogsQYJYvVHNvqNkdx9wx7smXnTxdF/+CK4lyU3s9riHnrLXuc TtVw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d20si1371473eds.29.2020.11.19.23.45.49; Thu, 19 Nov 2020 23:46:12 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727123AbgKTHo0 (ORCPT + 99 others); Fri, 20 Nov 2020 02:44:26 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:7960 "EHLO szxga06-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727082AbgKTHoY (ORCPT ); Fri, 20 Nov 2020 02:44:24 -0500 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4CcpTQ36lXzhddD; Fri, 20 Nov 2020 15:44:10 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.487.0; Fri, 20 Nov 2020 15:44:14 +0800 From: Qinglang Miao To: Steffen Maier , Benjamin Block , Heiko Carstens , Vasily Gorbik , Christian Borntraeger CC: , , "Qinglang Miao" Subject: [PATCH] scsi: zfcp: fix use-after-free in zfcp_unit_remove Date: Fri, 20 Nov 2020 15:48:54 +0800 Message-ID: <20201120074854.31754-1-miaoqinglang@huawei.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.113.25] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org kfree(port) is called in put_device(&port->dev) so that following use would cause use-after-free bug. The former put_device is redundant for device_unregister contains put_device already. So just remove it to fix this. Fixes: 86bdf218a717 ("[SCSI] zfcp: cleanup unit sysfs attribute usage") Reported-by: Hulk Robot Signed-off-by: Qinglang Miao --- drivers/s390/scsi/zfcp_unit.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/s390/scsi/zfcp_unit.c b/drivers/s390/scsi/zfcp_unit.c index e67bf7388..664b77853 100644 --- a/drivers/s390/scsi/zfcp_unit.c +++ b/drivers/s390/scsi/zfcp_unit.c @@ -255,8 +255,6 @@ int zfcp_unit_remove(struct zfcp_port *port, u64 fcp_lun) scsi_device_put(sdev); } - put_device(&unit->dev); - device_unregister(&unit->dev); return 0; -- 2.23.0