Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1383762pxb; Thu, 4 Nov 2021 01:02:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+/v5yig0b6F+boxWINrmVrAB/GVcY303HoqEHznxTsPF33sAePhr9v5XZVdFqdQXW2TQv X-Received: by 2002:a05:6638:258e:: with SMTP id s14mr2605248jat.111.1636012952458; 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=SBtHyKb/RwO6hpj0DLDw5KHSxeCvjO0wSWQ/lM1g4wBUMLVZzydvijtYZm9yCWolkG 7tTx5ntI9SkX4xLwrYjjaMM9+RN0WCF79dntKePjgyLeKn8H3YQtuRNFKIsERG6OBwjb 4G90Scns879PpD9W87g7m7sZfvguwdKZAVuvoFZQsY0TZZKbcHq6C+mFi44nlvbGaYxK sQA+c42FXN+cXxqqDNszUB3VztkyKGW25yxCr0gIhyDNomLr6MJHbOOACqWF2pi8yktg DT9zqpgiuWpwo7K1OIWUrSrEHr5W/smaszyA71idpTyzmuriSx1OhDkej596uLa1Ixq1 TqMQ== 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=mzSP3WbtkRk3iJ/4k/cji99VTS+E8qptrqWzL8CIc/o=; b=fzAIL26KGJWexsuR8+c8PWlHYaj0zDL0rU5L1Bq2Ns+6+8Mbv0nHi5JZ0AL1h0Ks6v MHAz1P1FpL3tjzU1U2zLWBzvL+e0O7faYx6KbgwB+wBjG156Nv53QIj0kjxu3osGSiSb nzZ0WEBtr9BBQFVHj2XpGDps3lcMNAK6O3QUd9y5pf9tIH/RiU0DlXTaYzefj0xO03dF ipwg+5C5JaAul2L99QSeozSCv99N/ynl2u49CYBKtA8ac6gQu96JF8HdhAZ2RNpCu+nH 65FtwoN2lrIJApHHlCQ1j7mvgtBscjO05QLd6TaL0vVILinD8hhjBSm1YUaWno9sIa/P dEGg== 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 k15si8359639ilo.180.2021.11.04.01.02.19; 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 S230397AbhKDID4 (ORCPT + 99 others); Thu, 4 Nov 2021 04:03:56 -0400 Received: from szxga03-in.huawei.com ([45.249.212.189]:27175 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230152AbhKDIDz (ORCPT ); Thu, 4 Nov 2021 04:03:55 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4HlGJH35S5zTgFS; Thu, 4 Nov 2021 15:59:43 +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 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 2/2] z2ram: add error handling support for add_disk() Date: Thu, 4 Nov 2021 16:33:19 +0800 Message-ID: <1636014799-20156-3-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/z2ram.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/block/z2ram.c b/drivers/block/z2ram.c index 4eef218..822df1d 100644 --- a/drivers/block/z2ram.c +++ b/drivers/block/z2ram.c @@ -318,6 +318,7 @@ static void z2_release(struct gendisk *disk, fmode_t mode) static int z2ram_register_disk(int minor) { struct gendisk *disk; + int err; disk = blk_mq_alloc_disk(&tag_set, NULL); if (IS_ERR(disk)) @@ -333,8 +334,11 @@ static int z2ram_register_disk(int minor) sprintf(disk->disk_name, "z2ram"); z2ram_gendisk[minor] = disk; - add_disk(disk); - return 0; + err = add_disk(disk); + if (err) + blk_cleanup_disk(disk); + + return err; } static int __init z2_init(void) -- 1.8.3.1