Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1589787pxb; Fri, 27 Aug 2021 12:19:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzkBQAa9k7N8nXqmK8C8d86HciCP3zeaXblGp9tMLjZQwB+8RrO5k+pc7BacpwnJbnzyhwS X-Received: by 2002:a05:6e02:1c2b:: with SMTP id m11mr7576090ilh.242.1630091999734; Fri, 27 Aug 2021 12:19:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630091999; cv=none; d=google.com; s=arc-20160816; b=kx9OHSZnaYRr128Eoan92F9TmM0mlM4c1edDnBN79m0efsi0F7taVex6h8YgboE+kT MqEF0yWLQNf3CvFLxGqiDrmkrYsEqXK3dhjPQ1m9Eu8NsRaGJZrahrKRc872k/R4VkK0 +6v7Kn0qvkKW1ZHlP9TLrxgwfXmefRoUum0JFFLV/4cbZUkeLz2gPddlMWbucEWvKtJY enofRuOb33+eCHNDkAWNBIJL98HjwdNYlrMj82VFNrKckRDfRyowddAF8SLniR3lFbbx A0veCST9Ga0fo+GNZgCjqS3KS/2daNMyHJjlvREh0b88C+fqaCOYGFggPfvBYENQKpHH SRyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vzfFGe77MiDtDAcsNEd4FFV6XUqpkLp7v2/+XiGswys=; b=Zc3NTotTvh24ZyIGh0wxF9E5fhfx9z3qHrFBzWfNO4biE0wO50sMDeiYX0abrq99LH lAs1TU+X+8dBGTH/ymvFL2wYSNCTkoopaVXLudOhLoW9cxTSn3fe2TAQImuNKh9jqDbg ZNg8D1NeBwYiqXkX13pYkVQIrvq8eSgAoaivyez/u0r1gWJHG7u1ruTTUu0EyJbGngqg pQmsGjZbKVYUaQ45iwy9DvuofEsbVsytMn7lLZ6Xcp7YZupHnB6rl+ecXnWPsznVdY1J C0wqSf9neqFjdeiQCWzG2ORYekSWT0h1LzNf7EY0yfoasfiU/2vaGjxbeLxdQ2Nf3lmY 9/kA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=isst7bA4; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o4si6548554ilf.130.2021.08.27.12.19.48; Fri, 27 Aug 2021 12:19:59 -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; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=isst7bA4; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231418AbhH0TT3 (ORCPT + 99 others); Fri, 27 Aug 2021 15:19:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231224AbhH0TTP (ORCPT ); Fri, 27 Aug 2021 15:19:15 -0400 Received: from bombadil.infradead.org (unknown [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBF14C061757; Fri, 27 Aug 2021 12:18:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=vzfFGe77MiDtDAcsNEd4FFV6XUqpkLp7v2/+XiGswys=; b=isst7bA45MsJEBHCIhkJx6Kczq YrMi78bLRt5qELgdWgY6H9Mgp+37YNSRQsfgXi4VM1MADrofBM9ydqTVaHxK/Mb9PPst7iuahgypW 86DjV+a3MdG1nqOFP2e9R/7/LoExU5RNSDgYWGFgZgOsn7cQGQmZmFVdsFt4b04RdjQi64HPxJC2Y TblDGK95B8LHVKYy5XjvUnNc7qRElN1IbsJ8V/4QSvZhz1Hefy4ZsPtYLUyEbJYVsV0jlytxSkfZi zdJLho+9svAaFsXC7A1pCEYiKEfCX1LVke+8CZuMNuC9thfpCFfwoMaHUOqgBZMY2OR0ZgHbFRARA 7BULMVAA==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mJhMg-00D5Aq-W4; Fri, 27 Aug 2021 19:18:11 +0000 From: Luis Chamberlain To: axboe@kernel.dk, colyli@suse.de, kent.overstreet@gmail.com, kbusch@kernel.org, sagi@grimberg.me, vishal.l.verma@intel.com, dan.j.williams@intel.com, dave.jiang@intel.com, ira.weiny@intel.com, konrad.wilk@oracle.com, roger.pau@citrix.com, boris.ostrovsky@oracle.com, jgross@suse.com, sstabellini@kernel.org, minchan@kernel.org, ngupta@vflare.org, senozhatsky@chromium.org Cc: xen-devel@lists.xenproject.org, nvdimm@lists.linux.dev, linux-nvme@lists.infradead.org, linux-bcache@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: [PATCH 01/10] block/brd: add error handling support for add_disk() Date: Fri, 27 Aug 2021 12:18:00 -0700 Message-Id: <20210827191809.3118103-2-mcgrof@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210827191809.3118103-1-mcgrof@kernel.org> References: <20210827191809.3118103-1-mcgrof@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: Luis Chamberlain 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 this is fixed, use the shiny new error handling. Signed-off-by: Luis Chamberlain --- drivers/block/brd.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/block/brd.c b/drivers/block/brd.c index 58ec167aa018..c2bf4946f4e3 100644 --- a/drivers/block/brd.c +++ b/drivers/block/brd.c @@ -372,6 +372,7 @@ static int brd_alloc(int i) struct brd_device *brd; struct gendisk *disk; char buf[DISK_NAME_LEN]; + int err = -ENOMEM; brd = kzalloc(sizeof(*brd), GFP_KERNEL); if (!brd) @@ -410,14 +411,19 @@ 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; + list_add_tail(&brd->brd_list, &brd_devices); return 0; +out_cleanup_disk: + blk_cleanup_disk(disk); out_free_dev: kfree(brd); - return -ENOMEM; + return err; } static void brd_probe(dev_t dev) -- 2.30.2