Skip to contentSkip to conversation

util/sysfs: do not fail on missing bind attributes

PATCH Applied Alison Schofield 1 participant 2 messages Aug 6 – Oct 23 libnvdimm: non-volatile memory device

lore
Share & tools
lore

Alison Schofield

author maintainer
#0 lore raw

PATCH 1/1 util/sysfs: do not fail on missing bind attributes

From: Tao Xu <[email protected]>

Kernel commit cb9cfff82f6a ("cxl/acpi: Simplify cxl_nvdimm_bridge probing") removed bind attrributes for cxl_pmem_region and cxl_nvdimm* objects.

__util_bind() currently attempts to write to the bind attribute of every entry under /sys/bus/cxl/drivers/. On kernels where some driver directories no longer provide that attribute, these attempts fail with ENOENT and produce misleading bind errors.

Check that the bind attribute exists before attempting the write.

[ as: commit log edited ]

---
 util/sysfs.c | 5 +++++
 1 file changed, 5 insertions(+)
util/sysfs.c +5 -0
index eaf4b60aacee..2dd4b48b4459 100644
@@ -258,6 +258,11 @@ int __util_bind(const char *devname, struct kmod_module *module,
 			continue;
 		}
 
+		if (access(drv_path, F_OK) != 0) {
+			free(drv_path);
+			continue;
+		}
+
 		rc = __sysfs_write_attr_quiet(ctx, drv_path, devname);
 		free(drv_path);
 		if (rc == 0)
Signature · 1 line
2.37.3
author maintainer Applied
#1 lore raw
Quoted 13 lines · Alison Schofield

From: Tao Xu <[email protected]>

Kernel commit cb9cfff82f6a ("cxl/acpi: Simplify cxl_nvdimm_bridge probing") removed bind attrributes for cxl_pmem_region and cxl_nvdimm* objects.

__util_bind() currently attempts to write to the bind attribute of every entry under /sys/bus/cxl/drivers/. On kernels where some driver directories no longer provide that attribute, these attempts fail with ENOENT and produce misleading bind errors.

Check that the bind attribute exists before attempting the write.

Quoted 7 lines

[ as: commit log edited ]

Applied to pending for NDCTL v86
https://github.com/pmem/ndctl/commit/3c8c3538a450