From patchwork Wed Aug 7 17:51:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 11082723 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 C9F811399 for ; Wed, 7 Aug 2019 20:29:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE5F1223A1 for ; Wed, 7 Aug 2019 20:29:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A1D44289F5; Wed, 7 Aug 2019 20:29:47 +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.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE 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 35A5E223A1 for ; Wed, 7 Aug 2019 20:29:47 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id EEB902130309C; Wed, 7 Aug 2019 13:32:16 -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=134.134.136.20; helo=mga02.intel.com; envelope-from=dan.j.williams@intel.com; receiver=linux-nvdimm@lists.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 93793212FD3F1 for ; Wed, 7 Aug 2019 13:32:15 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Aug 2019 11:05:57 -0700 X-IronPort-AV: E=Sophos;i="5.64,358,1559545200"; d="scan'208";a="168713377" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Aug 2019 11:05:57 -0700 Subject: [ndctl PATCH] ndctl/lib: Fix duplicate bus detection From: Dan Williams To: linux-nvdimm@lists.01.org Date: Wed, 07 Aug 2019 10:51:39 -0700 Message-ID: <156520029994.1268132.13388510714364773911.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-2-gc94f MIME-Version: 1.0 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Aneesh Kumar K.V" Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP After an ndctl_invalidate() event the next add_bus() invocation attempts to rescan for new bus objects and drop duplicate instances that match existing bus objects. However, the implementation mistakenly expects that ndctl_bus_get_provider_name() returns a unique identifier per-bus, but it is perfectly acceptable for unique buses to share a 'provider name'. Use the bus device-name to disambiguate buses with the same 'provider name'. Reported-by: Aneesh Kumar K.V Tested-by: Aneesh Kumar K.V Signed-off-by: Dan Williams --- ndctl/lib/libndctl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c index 4d9cc7e29c6b..6596f94edef8 100644 --- a/ndctl/lib/libndctl.c +++ b/ndctl/lib/libndctl.c @@ -889,7 +889,9 @@ static void *add_bus(void *parent, int id, const char *ctl_base) ndctl_bus_foreach(ctx, bus_dup) if (strcmp(ndctl_bus_get_provider(bus_dup), - ndctl_bus_get_provider(bus)) == 0) { + ndctl_bus_get_provider(bus)) == 0 + && strcmp(ndctl_bus_get_devname(bus_dup), + ndctl_bus_get_devname(bus)) == 0) { free_bus(bus, NULL); free(path); return bus_dup;