File ndctl-ndctl-lib-Fix-duplicate-bus-detection.patch of Package ndctl.14010
From d961a474be65c8195bb069c470b01f951bd2eb90 Mon Sep 17 00:00:00 2001
From: Dan Williams <dan.j.williams@intel.com>
Date: Wed, 7 Aug 2019 10:51:39 -0700
Subject: [PATCH] ndctl/lib: Fix duplicate bus detection
Patch-mainline: v67
Git-commit: d961a474be65c8195bb069c470b01f951bd2eb90
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 <aneesh.kumar@linux.ibm.com>
Tested-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
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;
--
2.23.0