- char *type_instance = NULL;
- if (blockdevice_format_basename && blockdevice_format == source)
- type_instance = strdup(basename(bdev->path));
- else
- type_instance = strdup(bdev->path);
+ char *type_instance = bdev->path;
+ char *path = NULL;
+ if (blockdevice_format_basename && blockdevice_format == source) {
+ path = strdup(bdev->path);
+ if (path == NULL) {
+ WARNING(PLUGIN_NAME
+ " plugin: error extracting the basename for '%s', skipped",
+ bdev->path);
+ continue;
+ }
+ type_instance = basename(path);
+ }