From patchwork Fri Aug 3 12:08:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ocean He X-Patchwork-Id: 10555041 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C0CB1139A for ; Fri, 3 Aug 2018 12:08:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B0C5D2C16B for ; Fri, 3 Aug 2018 12:08:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A46572C1AA; Fri, 3 Aug 2018 12:08:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DBA5E2C16B for ; Fri, 3 Aug 2018 12:08:53 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 68B4621A00AE6; Fri, 3 Aug 2018 05:08:53 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:400d:c0d::243; helo=mail-qt0-x243.google.com; envelope-from=oceanhehy@gmail.com; receiver=linux-nvdimm@lists.01.org Received: from mail-qt0-x243.google.com (mail-qt0-x243.google.com [IPv6:2607:f8b0:400d:c0d::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 310D121BADAB2 for ; Fri, 3 Aug 2018 05:08:51 -0700 (PDT) Received: by mail-qt0-x243.google.com with SMTP id z8-v6so5777537qto.9 for ; Fri, 03 Aug 2018 05:08:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=fYNPFFzCaPQ5hb7ccwLeOi3sJkgyu++vOi33TMFT6xs=; b=VsMhqqx3bzEAVdZmNqIkxgfTNXgeYRxbbImXkAvo3EGNCKex52cV4Jr6yJPYYL9gzB yLYXaIL7bsB6OdJSnCGE/9t/vG8J98VKfntMwV5MzO7cxGs+K/LiflnXTYiDX3C4Tkny HfNIMdKY4ibFJ1g3/8wc5XWXFW/Xn2bi/ndc+nJgZQ+U7JyVO22wIha3QMEpTOyGdiCk tlDbVvYwPOeNXxGCx80G9UI9X2sFQfZEplmgl8Kt/Bcx2OOnLQ+YPUPPB1fb6nysqgix nF+PMWJ+qR1OSCD9QS0ElG5XkJXnyZGItPoO0J7bz9YLu3n/b/78pDxSrWeaLVHW+wB4 MlnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=fYNPFFzCaPQ5hb7ccwLeOi3sJkgyu++vOi33TMFT6xs=; b=SyrMQyyRVoOnkJOvd192Lw6inwdaGOtrHlnHrrh8PqN5i7LjrpvKZ1T6/xWpORdHV+ NI/hXmyH8BVI4r24vcUxPYydoyDLm/LhQrY8/ezipVjrz8/exqQ7X2IQitUIU6F+dDR6 nrgo5fCWiGcfN/e15Xz9W1+rhsB6WFhF3Sr2ZMMz5JSWut8X5Cx+HD0t8+Pyb8P4Wloz Xjtl6zAweneSWLtgoHqA/KtplUouDBZGaIaAGfq/wfs7iFNaBsztR47wjB+dcWW4hkIE 6J+I26VRcm+8WgsWpN6KWny2TLp2YqnRpFTkHpAhyp8DwtyVcDOM4VB8TQwTJz0dzGNx R+Ew== X-Gm-Message-State: AOUpUlH89J/GZAzqIyZfWYX+VmoMZflqdVTPLGUYtydyE+eZxqhUTtUY nOTLjYsFwu0Zb9we0CqvqSc= X-Google-Smtp-Source: AAOMgpf4OiefWaqvgYEYMcJDSYUlwmsTcvHuGEXQXrk0Wv5tMANO1sJj6Z4dryrnvzVxBLvOuadskQ== X-Received: by 2002:ac8:40d1:: with SMTP id f17-v6mr3481424qtm.96.1533298130929; Fri, 03 Aug 2018 05:08:50 -0700 (PDT) Received: from localhost.localdomain ([45.56.155.220]) by smtp.gmail.com with ESMTPSA id r27-v6sm4801509qkr.17.2018.08.03.05.08.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Aug 2018 05:08:50 -0700 (PDT) From: Ocean He To: dan.j.williams@intel.com, ross.zwisler@linux.intel.com, vishal.l.verma@intel.com, dave.jiang@intel.com Subject: [PATCH] libnvdimm, bus: check id immediately following ida_simple_get Date: Fri, 3 Aug 2018 08:08:33 -0400 Message-Id: <1533298113-17495-1-git-send-email-oceanhehy@gmail.com> X-Mailer: git-send-email 1.8.3.1 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ocean He , linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP From: Ocean He The id check was not executed immediately following ida_simple_get. Just change the codes position, without function change. Signed-off-by: Ocean He Reviewed-by: Vishal Verma --- drivers/nvdimm/bus.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c index 27902a8..ab28e7c 100644 --- a/drivers/nvdimm/bus.c +++ b/drivers/nvdimm/bus.c @@ -350,12 +350,12 @@ struct nvdimm_bus *nvdimm_bus_register(struct device *parent, INIT_LIST_HEAD(&nvdimm_bus->mapping_list); init_waitqueue_head(&nvdimm_bus->probe_wait); nvdimm_bus->id = ida_simple_get(&nd_ida, 0, 0, GFP_KERNEL); - mutex_init(&nvdimm_bus->reconfig_mutex); - badrange_init(&nvdimm_bus->badrange); if (nvdimm_bus->id < 0) { kfree(nvdimm_bus); return NULL; } + mutex_init(&nvdimm_bus->reconfig_mutex); + badrange_init(&nvdimm_bus->badrange); nvdimm_bus->nd_desc = nd_desc; nvdimm_bus->dev.parent = parent; nvdimm_bus->dev.release = nvdimm_bus_release;