mirror of
https://github.com/ceph/ceph
synced 2024-12-19 01:46:00 +00:00
Merge pull request #5507 from athanatos/wip-12436
blkdev.cc::get_device_by_uuid: do not leak cache Reviewed-by: Sage Weil <sage@redhat.com>
This commit is contained in:
commit
2a7605380c
@ -191,21 +191,29 @@ int get_device_by_uuid(uuid_d dev_uuid, const char* label, char* partition,
|
||||
|
||||
if (blkid_get_cache(&cache, NULL) >= 0)
|
||||
dev = blkid_find_dev_with_tag(cache, label, (const char*)uuid_str);
|
||||
else
|
||||
rc = -EINVAL;
|
||||
|
||||
if (dev) {
|
||||
temp_partition_ptr = blkid_dev_devname(dev);
|
||||
strncpy(partition, temp_partition_ptr, PATH_MAX);
|
||||
rc = get_block_device_base(partition, basename,
|
||||
sizeof(basename));
|
||||
if (rc >= 0)
|
||||
if (rc >= 0) {
|
||||
strncpy(device, basename, sizeof(basename));
|
||||
else
|
||||
return -ENODEV;
|
||||
|
||||
return 0;
|
||||
rc = 0;
|
||||
} else {
|
||||
rc = -ENODEV;
|
||||
}
|
||||
} else {
|
||||
rc = -EINVAL;
|
||||
}
|
||||
|
||||
return -EINVAL;
|
||||
/* From what I can tell, blkid_put_cache cleans up dev, which
|
||||
* appears to be a pointer into cache, as well */
|
||||
if (cache)
|
||||
blkid_put_cache(cache);
|
||||
return rc;
|
||||
}
|
||||
#elif defined(__APPLE__)
|
||||
#include <sys/disk.h>
|
||||
|
Loading…
Reference in New Issue
Block a user