Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp3971618pxb; Mon, 30 Aug 2021 15:12:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy6six6Vp/OxrE3dOvoAV91rE5ucQQHY1u/eeS27QFSTXH5vPdxPbyubI4+MeEJGJKufiVo X-Received: by 2002:a92:cb08:: with SMTP id s8mr17351670ilo.166.1630361526654; Mon, 30 Aug 2021 15:12:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630361526; cv=none; d=google.com; s=arc-20160816; b=E1jvC0zUZQC8SSxyJ/AOb2UFgwF3gExbwWThrB7tVY9tLLudojiSOZjzy2weLig46x bYm37lds2QgWm5QId1yTmgMKzBV80kFqgwvGJrl4kIwk27W7VfC0Xzf8x5qKKGcnDZby qEBGubodIk14FcbDGCuGADsqQyjAhPYRLS9yTqFT3huyBy9KoZ5Lj6iJBH2N1I+yT9/G aT3C6Yey5vAfDrswDm0Ja9vhpLwpmX3oVWk4+Q89Dv2IyeEO9afTUSiii6UB5HMNsr7t wDs8VlG1AmP9QZ5pYiDhCfQRLQviZAf0VKI17ONJLgxxAsx474ik3z0zMlTdLbFcJsK5 33xA== 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=USXvhbRCxERAyh/lmGR9Fl4mrHzKV90ugeqiIsioc48=; b=MbBip6+l/Di9+8/BHcTTE3bEiPA/DmAgdwnUO43/O+bGlPW/a5XFNlZg7AAEej/Tnu /cfhqBT3rXi/4hF+MRBVgKxC6B6ZqYqrcjsLBZqgVlmXli7bQzqV9Zixh5fdSZ/5LHsN LrBBtPuJW2C0WLm3cFTl/JK9rCS6m10AUDOnxjUNZvd6hBnaJeMb4Y1IklE/vfgWP4ve Oq9GFQ06FoDyv+oKbxa/DR9SD2Td+0d0ivrMd6ST8ULOI8ONFb4mUEAi8sVkGMo43eg9 WByHY5RLv/NWjbTImTKKJmoshm17XW7QGFLBtfdhTOfOkPYdHwGdLFVbRUavBzr2tR9m vIlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b="hct/qvJv"; 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 m18si16792067jav.88.2021.08.30.15.11.55; Mon, 30 Aug 2021 15:12:06 -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="hct/qvJv"; 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 S239070AbhH3WLt (ORCPT + 99 others); Mon, 30 Aug 2021 18:11:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238766AbhH3WLZ (ORCPT ); Mon, 30 Aug 2021 18:11:25 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF128C0617AE; Mon, 30 Aug 2021 15:10:27 -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=USXvhbRCxERAyh/lmGR9Fl4mrHzKV90ugeqiIsioc48=; b=hct/qvJvbyLNLIeUzs1hESxsqy dsG5KX/2NuM4tcVggxsBGSS4l5EmQx45dJlzr4pFEzZWqDEZyLAolRwXHa3mmukZRbZd9TJyYiUJX BpCU8zTJva+L3uomzVi3C7WTCgqVhM4lGPchRtQxmp1FSZqSbf7HWpv4dMxGeFGhAqU4F6jUznbBS PeQkoOqgM99h4NlleYRgduJFM0FTaFoUV8h0jBCi03DqrefkeYtc47QnUw+/K8/CPrG7ih0nvD4+U vYtDk60Q7KSO0CLLZLkAJcEfTyuLY1mRLEj2jh+MTKTUXHgIoxiXZwCOyjdwz9w54hPzf5GhoRREG 89o7fnVw==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mKpTj-000khO-To; Mon, 30 Aug 2021 22:10:07 +0000 From: Luis Chamberlain To: axboe@kernel.dk, justin@coraid.com, geert@linux-m68k.org, ulf.hansson@linaro.org, hare@suse.de, tj@kernel.org, philipp.reisner@linbit.com, lars.ellenberg@linbit.com, jdike@addtoit.com, richard@nod.at, anton.ivanov@cambridgegreys.com, johannes.berg@intel.com, chris.obbard@collabora.com, krisman@collabora.com, zhuyifei1999@gmail.com, thehajime@gmail.com, chris@zankel.net, jcmvbkbc@gmail.com, tim@cyberelk.net Cc: linux-xtensa@linux-xtensa.org, linux-um@lists.infradead.org, linux-m68k@lists.linux-m68k.org, drbd-dev@lists.linbit.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: [PATCH 05/15] um/drivers/ubd_kern: add error handling support for add_disk() Date: Mon, 30 Aug 2021 15:09:50 -0700 Message-Id: <20210830221000.179369-6-mcgrof@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210830221000.179369-1-mcgrof@kernel.org> References: <20210830221000.179369-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. ubd_disk_register() never returned an error, so just fix that now and let the caller handle the error condition. Signed-off-by: Luis Chamberlain --- arch/um/drivers/ubd_kern.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c index cd9dc0556e91..81045c199c30 100644 --- a/arch/um/drivers/ubd_kern.c +++ b/arch/um/drivers/ubd_kern.c @@ -854,8 +854,8 @@ static const struct attribute_group *ubd_attr_groups[] = { NULL, }; -static void ubd_disk_register(int major, u64 size, int unit, - struct gendisk *disk) +static int ubd_disk_register(int major, u64 size, int unit, + struct gendisk *disk) { disk->major = major; disk->first_minor = unit << UBD_SHIFT; @@ -872,7 +872,7 @@ static void ubd_disk_register(int major, u64 size, int unit, disk->private_data = &ubd_devs[unit]; disk->queue = ubd_devs[unit].queue; - device_add_disk(&ubd_devs[unit].pdev.dev, disk, ubd_attr_groups); + return device_add_disk(&ubd_devs[unit].pdev.dev, disk, ubd_attr_groups); } #define ROUND_BLOCK(n) ((n + (SECTOR_SIZE - 1)) & (-SECTOR_SIZE)) @@ -919,10 +919,15 @@ static int ubd_add(int n, char **error_out) blk_queue_write_cache(ubd_dev->queue, true, false); blk_queue_max_segments(ubd_dev->queue, MAX_SG); blk_queue_segment_boundary(ubd_dev->queue, PAGE_SIZE - 1); - ubd_disk_register(UBD_MAJOR, ubd_dev->size, n, disk); + err = ubd_disk_register(UBD_MAJOR, ubd_dev->size, n, disk); + if (err) + goto out_cleanup_disk; + ubd_gendisk[n] = disk; return 0; +out_cleanup_disk: + blk_cleanup_disk(disk); out_cleanup_tags: blk_mq_free_tag_set(&ubd_dev->tag_set); out: -- 2.30.2