Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1383758pxb; Thu, 4 Nov 2021 01:02:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJylkKPvFY4dhL6k3t90zcOms94JzjSoaSkQnMe3wTC4WO7FJHMJ4/nlCKXAyMnqXqVIGAY4 X-Received: by 2002:a05:6e02:1c8f:: with SMTP id w15mr31274566ill.147.1636012952461; Thu, 04 Nov 2021 01:02:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1636012952; cv=none; d=google.com; s=arc-20160816; b=f8bmdcMcH9WYOQ2KSjZjVegBP1V+exa19J8kJisWNttWnN/k3TjPbQ7ET0aRj0MniX 90SczE4/Pk/FbubS+tTJVbk9ha8bc+mjV2TtDQID/axlqty3pLSumNpXiORd38fjyYkY B9XhmHCqPZ8oDJBZEmLy2c7q0NOaWCDb+KHAvGrsD2akGhLtIYcmYeztbRQsHq2P+pyS wM3dFz5yyjetymeZ9lOcDZE8OydqgGG8Y1gqMj29R6csTGq6uCCLn9ImRwZyNpT/hD8U MMHE5Fs3LU9ekutzi8PSNM0D9Xl5tQGs5s8sua+Ceq4eFlPw+OzkOgho1MytUZX+jQP4 xMuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=3C/AzgHQr90dvuad59f7SilhAhoSywHydUVSOGD0Ntc=; b=GjTyrDwaCW9G6tIi/I8toZNEEqFtQmHj2BRoXed8z8M5ixNkrZfj9cluduh1dW7IWE X9svTnKKhU5ib16mVvY3HE/luMq+NwshY82hHL+cAtCNWGV1ZkU5j6KEiru32KUa61fR RAey12w7gqDUSSz+3WpxZugq28ctfi+lEDyKoLTPYVYAdC6GnvaKH7Krr2VgQfxt5PDn 25GL7rcCw1ldbhpuOOjEXkVlqmHIAwGVY6qHXlDhhQYJIh/ARRoMW2H99Z7owlrrrjjH iKhY/wj9Jl+TthZTT6vZ8zKdZwcKwYtZdziaZwef/zkUZFJfBjaTVfspREVZZOG5za7k HfZQ== 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 k5si1301250ilu.108.2021.11.04.01.02.18; Thu, 04 Nov 2021 01:02:32 -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 S230301AbhKDIDy (ORCPT + 99 others); Thu, 4 Nov 2021 04:03:54 -0400 Received: from szxga08-in.huawei.com ([45.249.212.255]:27113 "EHLO szxga08-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230084AbhKDIDx (ORCPT ); Thu, 4 Nov 2021 04:03:53 -0400 Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4HlGHb0Z4yz1DJ7s; Thu, 4 Nov 2021 15:59:07 +0800 (CST) Received: from dggpeml500019.china.huawei.com (7.185.36.137) by dggemv703-chm.china.huawei.com (10.3.19.46) 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 16:01:13 +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 16:01:12 +0800 From: Wu Bo To: CC: , , , Subject: [PATCH 1/2] brd: add error handling support for add_disk() Date: Thu, 4 Nov 2021 16:33:18 +0800 Message-ID: <1636014799-20156-2-git-send-email-wubo40@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1636014799-20156-1-git-send-email-wubo40@huawei.com> References: <1636014799-20156-1-git-send-email-wubo40@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) 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 We never checked for errors on add_disk() as this function returned void. Now that is fixed. So add error handling support for add_disk(). Signed-off-by: Wu Bo --- drivers/block/brd.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/block/brd.c b/drivers/block/brd.c index aa04727..34a0d9c 100644 --- a/drivers/block/brd.c +++ b/drivers/block/brd.c @@ -370,6 +370,7 @@ static int brd_alloc(int i) struct brd_device *brd; struct gendisk *disk; char buf[DISK_NAME_LEN]; + int err; mutex_lock(&brd_devices_mutex); list_for_each_entry(brd, &brd_devices, brd_list) { @@ -420,10 +421,14 @@ static int brd_alloc(int i) /* Tell the block layer that this is not a rotational device */ blk_queue_flag_set(QUEUE_FLAG_NONROT, disk->queue); blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, disk->queue); - add_disk(disk); + err = add_disk(disk); + if (err) + goto out_cleanup_disk; return 0; +out_cleanup_disk: + blk_cleanup_disk(disk); out_free_dev: mutex_lock(&brd_devices_mutex); list_del(&brd->brd_list); -- 1.8.3.1