Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4765485pxj; Wed, 12 May 2021 12:45:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzts0G0TpmEDc4LHC3DCqvUrGo5vWO+2dwXhbXA8m/aoR/KGxTHSZMgpKEmM4L4ftPSfDyq X-Received: by 2002:a17:907:1629:: with SMTP id hb41mr40485265ejc.316.1620848755536; Wed, 12 May 2021 12:45:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620848755; cv=none; d=google.com; s=arc-20160816; b=oSIoRQIaTTfzobI/nYkUeZdCeAyN5zwD+dVuUP4p2WUY07dzDQXL3h+W3prXAgDyXB +mQdxRvBFeQnVPuXd2yQrP0jMUYUSRSYVx5mOszzVLftzFLfhvvNnSNzjO+VHM46tPa3 4BT4mibNmRlSJ64Y0MKjmF22iEvji+DRySCEZavDQj4rjhiLz+qdUBkMNrNDSAwgy0wb 6ZGv+kuw9qQ1Vh0ncczUWIz7hFPbKOVPn5qGGbIqiL+8qZVyv+MFk5/sgy3khiIgD5oj TMCvYz6uu4L/qANrd0g1F8oxciLHipURS3xraL4VeJXMQndU4WjWeZpUexFckpc2x3ti 95PA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=+x6P3UURLju1gGDfK5YUcOa9nQOnLlZ7h/OsVA62i2I=; b=ZwEnAW6h7WTyTos3+lMFGDuEZefdPxoyKn5+VLXJ/ARcLmymfgO3AUGkREDXASE5Ru RxC/Ax9iNzQgbfNO++Tn/yrA4Ak0GPFPRHt/la3n3icoM9kNndlh7gntueoxiqsqeO2d 8tCXpUuMEvak68kMeRMfMh3Gc+Z8tgjfpPrP0aFZZ1oI+dV3SL2befjwW8SJ2LqSjHVc BAbm73QSH5PrbZ3gEP/ZWmsePoq79G5xHYKpvqVhV95ZMlntpXuKywupvYpI8q3OSa7B Xipk4tYJUA2CRN4gH05fMZ8mH4GOi6jjdWVj8VHjBBXqXpb0LURfB36K4iTDFtgbUB3k PnGg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j3si692382ejy.597.2021.05.12.12.45.32; Wed, 12 May 2021 12:45:55 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380649AbhELTcO (ORCPT + 99 others); Wed, 12 May 2021 15:32:14 -0400 Received: from mx2.suse.de ([195.135.220.15]:38016 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346307AbhELRNN (ORCPT ); Wed, 12 May 2021 13:13:13 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 9EDD9B1BF; Wed, 12 May 2021 17:12:04 +0000 (UTC) Subject: Re: [PATCH v1 7/8] null_blk: add error handling support for add_disk() To: Luis Chamberlain Cc: axboe@kernel.dk, bvanassche@acm.org, ming.lei@redhat.com, hch@infradead.org, jack@suse.cz, osandov@fb.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org References: <20210512064629.13899-1-mcgrof@kernel.org> <20210512064629.13899-8-mcgrof@kernel.org> <842b6a8d-8880-a0da-a38b-39378dc6ebb9@suse.de> <20210512164709.GA4332@42.do-not-panic.com> From: Hannes Reinecke Message-ID: Date: Wed, 12 May 2021 19:12:03 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.9.1 MIME-Version: 1.0 In-Reply-To: <20210512164709.GA4332@42.do-not-panic.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/12/21 6:47 PM, Luis Chamberlain wrote: > On Wed, May 12, 2021 at 05:16:39PM +0200, Hannes Reinecke wrote: >> On 5/12/21 8:46 AM, Luis Chamberlain wrote: >>> 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/null_blk/main.c | 9 +++++++-- >>> 1 file changed, 7 insertions(+), 2 deletions(-) >>> >>> diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c >>> index 5f006d9e1472..2346d1292b26 100644 >>> --- a/drivers/block/null_blk/main.c >>> +++ b/drivers/block/null_blk/main.c >>> @@ -1699,6 +1699,7 @@ static int init_driver_queues(struct nullb *nullb) >>> static int null_gendisk_register(struct nullb *nullb) >>> { >>> + int ret; >>> sector_t size = ((sector_t)nullb->dev->size * SZ_1M) >> SECTOR_SHIFT; >>> struct gendisk *disk; >>> @@ -1719,13 +1720,17 @@ static int null_gendisk_register(struct nullb *nullb) >>> strncpy(disk->disk_name, nullb->disk_name, DISK_NAME_LEN); >>> if (nullb->dev->zoned) { >>> - int ret = null_register_zoned_dev(nullb); >>> + ret = null_register_zoned_dev(nullb); >>> if (ret) >>> return ret; >>> } >>> - add_disk(disk); >>> + ret = add_disk(disk); >>> + if (ret) { >> >> unregister_zoned_device() ? > > That function does not exist, do you mean null_free_zoned_dev()? If so > that is done by the caller. > What I intended to say is that you are calling 'null_register_zoned_dev()' at one point, but don't call a cleanup function if there is an error later in the path, leaving the caller to guess whether null_register_zoned_dev() has been called or not. So we should call the cleanup function here, too. Cheers, Hannes -- Dr. Hannes Reinecke Kernel Storage Architect hare@suse.de +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer