Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1365823pxb; Thu, 4 Nov 2021 00:36:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwIHg/oFILoGPJpiIJjArNPsG3xZE8R4v+g4YHsRwxf2OL/4eCalit4140h2kC3JuIKLE4w X-Received: by 2002:a05:6e02:12c3:: with SMTP id i3mr25261407ilm.316.1636011379916; Thu, 04 Nov 2021 00:36:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1636011379; cv=none; d=google.com; s=arc-20160816; b=p52Wbtr70Pp5iFxUnUBNc6avQCJSF8B22UtZBvdisaOckl/wDNaSft24qUXdDPxzQ9 G/2x9tysZgbxl9BZsnlVokAHzZkCijVYJ1VLZVanoMKd8XIM1CbNBkBRJxBuEezC9JHE 9cxFZJoCdUzHBboH7n5HBbxBdMMqIK/1e2QX3Tz1JLWO502ZkL6NdeViPaITf76KyzNV 1LGRoTJaywx0KfRsJhLKuuT7esgenSGIK+TwYvLqa/DXCah/FkiKunTWk2kUk4ztSlxT mI5VjJJ+3Xq93QvdCAfO0aZC3eb8UngFNJ1zNmeMzkjMYh/K3lqdZbFXqbp89toAl/CB Lh7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=Ob1QO7W7cJdbTW7aOeHTPTSpKxOqjUuifFnXs27MuhI=; b=BSyG+UjgQ12tVBfOX6+1S1ASYtaABNfsACMMbwuGdakE/NWD4gx3DDvWFE0Bh/Aktz KPQJjJnptTnQSzeciHRLxsv4AWrowTRp3/eD3RrH5A+Ab6gWL3J3ma5OCOiZb/q/T0ju xdH3HyHOtWN1RHnOFCCBJrpchtzLSccwvDjamDWM0/vWnBDJpBsrO0VClYCtzc1PdGur sJiUX5W3dY23MWbydwNDEhKSUll1UzIXzH1rAUBq7qQ6bMgfv1EIDzlIiVXwLOQ/Guaq sea6h71tsA18s88CKKBbJw3c/kCWUCh2YGp+M41ztjrI9XR+p91WDDzLhJY8oFDbXex2 MePA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a13si2103675ilv.53.2021.11.04.00.36.07; Thu, 04 Nov 2021 00:36:19 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230361AbhKDHhr (ORCPT + 99 others); Thu, 4 Nov 2021 03:37:47 -0400 Received: from szxga08-in.huawei.com ([45.249.212.255]:27112 "EHLO szxga08-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230084AbhKDHhq (ORCPT ); Thu, 4 Nov 2021 03:37:46 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.56]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4HlFjN6cPgz1DJ4R; Thu, 4 Nov 2021 15:32:56 +0800 (CST) Received: from dggpeml500019.china.huawei.com (7.185.36.137) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.15; Thu, 4 Nov 2021 15:35:02 +0800 Received: from huawei.com (10.175.124.27) by dggpeml500019.china.huawei.com (7.185.36.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.15; Thu, 4 Nov 2021 15:35:02 +0800 From: Wu Bo To: , CC: , , , , Subject: [PATCH] drbd: Fix double free problem in drbd_create_device Date: Thu, 4 Nov 2021 16:07:09 +0800 Message-ID: <1636013229-26309-1-git-send-email-wubo40@huawei.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpeml500019.china.huawei.com (7.185.36.137) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In drbd_create_device(), the 'out_no_io_page' lable has called blk_cleanup_disk() when return failed. So remove the 'out_cleanup_disk' lable to avoid double free the disk pointer. Fixes: e92ab4eda516 ("drbd: add error handling support for add_disk()") Signed-off-by: Wu Bo --- drivers/block/drbd/drbd_main.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index 19db80a..53ba2dd 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c @@ -2796,7 +2796,7 @@ enum drbd_ret_code drbd_create_device(struct drbd_config_context *adm_ctx, unsig err = add_disk(disk); if (err) - goto out_cleanup_disk; + goto out_idr_remove_vol; /* inherit the connection state */ device->state.conn = first_connection(resource)->cstate; @@ -2810,8 +2810,6 @@ enum drbd_ret_code drbd_create_device(struct drbd_config_context *adm_ctx, unsig drbd_debugfs_device_add(device); return NO_ERROR; -out_cleanup_disk: - blk_cleanup_disk(disk); out_idr_remove_vol: idr_remove(&connection->peer_devices, vnr); out_idr_remove_from_resource: -- 1.8.3.1