From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C683EC6379F for ; Fri, 20 Nov 2020 07:45:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8BF52223AC for ; Fri, 20 Nov 2020 07:45:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727140AbgKTHo0 (ORCPT ); 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