Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp933736pxb; Wed, 1 Sep 2021 13:05:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4hGkzCVZDGvb74xwxTcZgJSDYm4A3XOAiTV9Uq6XTPPVE2ZcY3OEVR+E6HwIEHzPsZB/0 X-Received: by 2002:a17:906:7302:: with SMTP id di2mr1262327ejc.409.1630526717192; Wed, 01 Sep 2021 13:05:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630526717; cv=none; d=google.com; s=arc-20160816; b=uEHs/r/Dg7NsSeNYRsAZ9t+meC+Qxnd9bwIVPZKjBhd38VmQ+3rV8/e/AH2sgBbnLq ycas3vbsbGFCGyzAhlGzAIDaMrL75JejSq8Hn5PQ52XZY3xSI8bSa5oeubo3ef/fw4ZT ArWg0GBIfDIe6cyvfKS9VO/H+b/30F1Gp9YTei+XLWi4sskyLlCtNKE9zMvvyr6OWQNV SpY5zqiG1giqUfabUyrN2kuIlUp/sNPj7aiGoI+/P6xHmyFvNc3Pf7dA1zHMGMfDeHsq 20TgIKbalMK0EMjl4gyzk+GgXXs4sb1eWc8uhjYPr/g6H0XrNqIL/u3Mm9uvPw9Rmw31 E+ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:organization:subject:cc:to:from; bh=Xuqw49TEzULz4Yq8b5G9QbTGf2792wTVV6VSr4xABeU=; b=wRMNXPOmMSxMcm4dKJg4m9IyJ+BbFKtJwbsJvoA1dsbz0ndSJbfjoGoLM+Ksj9rCyd hpZFmUh4jnFSC5cfHEx5roMrMBQnmQHrpb5BVJZ6/3C5kKmyEKHn2QmilnbzOto64lYU wDU1ptMVBpdAGt+VBephwHH5SHuvjMdSrRBJ4hkCgo3V/OsADJxHfqOvIDDML5d3gq/S 85XNpKggsISps5+SoViMZr+RcqsFcsMaj8En6GeuS6nku1jP5kr4M+7Xl6uLN2//0i0d 2AIL2DVWIY0WWUeWzxbVamj4B86NwBtV704ERj1UUydyXHSHgrVo1lPH0D6MVLFe/fdl VnBA== 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=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l3si799605ejd.407.2021.09.01.13.04.28; Wed, 01 Sep 2021 13:05:17 -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=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343706AbhIAP0C (ORCPT + 99 others); Wed, 1 Sep 2021 11:26:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343529AbhIAPZ5 (ORCPT ); Wed, 1 Sep 2021 11:25:57 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7ED55C061575; Wed, 1 Sep 2021 08:25:00 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id 8ECC91F43EF3 From: Gabriel Krisman Bertazi To: Luis Chamberlain Cc: 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, zhuyifei1999@gmail.com, thehajime@gmail.com, chris@zankel.net, jcmvbkbc@gmail.com, tim@cyberelk.net, 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 Subject: Re: [PATCH 05/15] um/drivers/ubd_kern: add error handling support for add_disk() Organization: Collabora References: <20210830221000.179369-1-mcgrof@kernel.org> <20210830221000.179369-6-mcgrof@kernel.org> Date: Wed, 01 Sep 2021 11:24:55 -0400 In-Reply-To: <20210830221000.179369-6-mcgrof@kernel.org> (Luis Chamberlain's message of "Mon, 30 Aug 2021 15:09:50 -0700") Message-ID: <8735qotj20.fsf@collabora.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Luis Chamberlain writes: > 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 Reviewed-by: Gabriel Krisman Bertazi > --- > 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: -- Gabriel Krisman Bertazi