Skip to content

Commit

Permalink
Merge pull request #5030 from pmem/stable-1.9
Browse files Browse the repository at this point in the history
Stable 1.9
  • Loading branch information
pbalcer authored Oct 26, 2020
2 parents b906ac3 + 84b9154 commit 8c11cf0
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/libpmem2/usc_ndctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ pmem2_source_device_id(const struct pmem2_source *src, char *id, size_t *len)
struct ndctl_dimm *dimm;
int ret;
struct ndctl_region *region = NULL;
const char *dimm_uid;

if (src->type == PMEM2_SOURCE_ANON) {
ERR("Anonymous source does not have device id");
Expand Down Expand Up @@ -113,14 +114,23 @@ pmem2_source_device_id(const struct pmem2_source *src, char *id, size_t *len)

if (id == NULL) {
ndctl_dimm_foreach_in_region(region, dimm) {
dimm_uid = ndctl_dimm_get_unique_id(dimm);
if (dimm_uid == NULL) {
ret = PMEM2_E_NOSUPP;
goto err;
}
len_base += strlen(ndctl_dimm_get_unique_id(dimm));
}
goto end;
}

size_t count = 1;
ndctl_dimm_foreach_in_region(region, dimm) {
const char *dimm_uid = ndctl_dimm_get_unique_id(dimm);
dimm_uid = ndctl_dimm_get_unique_id(dimm);
if (dimm_uid == NULL) {
ret = PMEM2_E_NOSUPP;
goto err;
}
count += strlen(dimm_uid);
if (count > *len) {
ret = PMEM2_E_BUFFER_TOO_SMALL;
Expand Down

0 comments on commit 8c11cf0

Please sign in to comment.