Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753883AbdDKKmC (ORCPT ); Tue, 11 Apr 2017 06:42:02 -0400 Received: from mail-wr0-f178.google.com ([209.85.128.178]:36504 "EHLO mail-wr0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752731AbdDKKl3 (ORCPT ); Tue, 11 Apr 2017 06:41:29 -0400 Subject: Re: [PATCH 2/4] lightnvm: fix cleanup order of disk on init error To: =?UTF-8?Q?Javier_Gonz=c3=a1lez?= References: <1491589874-26818-1-git-send-email-javier@cnexlabs.com> <1491589874-26818-2-git-send-email-javier@cnexlabs.com> Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?Q?Javier_Gonz=c3=a1lez?= From: =?UTF-8?Q?Matias_Bj=c3=b8rling?= Message-ID: Date: Tue, 11 Apr 2017 12:41:26 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <1491589874-26818-2-git-send-email-javier@cnexlabs.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1340 Lines: 48 On 04/07/2017 08:31 PM, Javier González wrote: > Reorder disk allocation such that the disk structure can be put > safely. > > Signed-off-by: Javier González > --- > drivers/lightnvm/core.c | 14 +++++++------- > 1 file changed, 7 insertions(+), 7 deletions(-) > > diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c > index da4c082..28e69a7 100644 > --- a/drivers/lightnvm/core.c > +++ b/drivers/lightnvm/core.c > @@ -263,15 +263,15 @@ static int nvm_create_tgt(struct nvm_dev *dev, struct nvm_ioctl_create *create) > goto err_t; > } > > + tdisk = alloc_disk(0); > + if (!tdisk) > + goto err_dev; > + > tqueue = blk_alloc_queue_node(GFP_KERNEL, dev->q->node); > if (!tqueue) > - goto err_dev; > + goto err_disk; > blk_queue_make_request(tqueue, tt->make_rq); > > - tdisk = alloc_disk(0); > - if (!tdisk) > - goto err_queue; > - > sprintf(tdisk->disk_name, "%s", create->tgtname); > tdisk->flags = GENHD_FL_EXT_DEVT; > tdisk->major = 0; > @@ -307,9 +307,9 @@ static int nvm_create_tgt(struct nvm_dev *dev, struct nvm_ioctl_create *create) > if (tt->exit) > tt->exit(targetdata); > err_init: > - put_disk(tdisk); > -err_queue: > blk_cleanup_queue(tqueue); > +err_disk: > + put_disk(tdisk); > err_dev: > nvm_remove_tgt_dev(tgt_dev, 0); > err_t: > Thanks. Applied for 4.12.