Skip to contentSkip to conversation

nvdimm: use the right length of "pmem"

PATCH In review Nicolas Iooss 2 participants 3 messages Oct 29, 2016 – Oct 30, 2016 libnvdimm: non-volatile memory device

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvdimm: use the right length of "pmem"

In order to test that the name of a resource begins with "pmem", call strncmp() with 4 as length instead of 3 to match the whole prefix.

Fixes 16660eaea0cc ("libnvdimm, namespace: update label implementation

for multi-pmem")

---
 drivers/nvdimm/label.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvdimm/label.c +1 -1
index fac7cabe8f56..dd615345699f 100644
@@ -938,7 +938,7 @@ int nd_pmem_namespace_label_update(struct nd_region *nd_region,
 		}
 
 		for_each_dpa_resource(ndd, res)
-			if (strncmp(res->name, "pmem", 3) == 0)
+			if (strncmp(res->name, "pmem", 4) == 0)
 				count++;
 		WARN_ON_ONCE(!count);
 
Signature · 6 lines
2.10.1

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#1 lore raw
Quoted 6 lines · Nicolas Iooss

In order to test that the name of a resource begins with "pmem", call strncmp() with 4 as length instead of 3 to match the whole prefix.

Fixes 16660eaea0cc ("libnvdimm, namespace: update label implementation

for multi-pmem")

Thanks, although I would not call this out as a fix since the length parameter could be 1 and still do the right thing. I.e. we're distinguishing "blk" from "pmem" resources. I'll add this for 4.10 as a cleanup.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#2 lore raw
Quoted 5 lines · Dan Williams
Quoted 3 lines · Nicolas Iooss

In order to test that the name of a resource begins with "pmem", call strncmp() with 4 as length instead of 3 to match the whole prefix.

Quoted 8 lines
Quoted 3 lines
Fixes 16660eaea0cc ("libnvdimm, namespace: update label implementation

for multi-pmem")

Thanks, although I would not call this out as a fix since the length parameter could be 1 and still do the right thing. I.e. we're distinguishing "blk" from "pmem" resources. I'll add this for 4.10 as a cleanup.

All right. Thanks for your quick reply!

Nicolas
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm