mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
cov: check for dev_iter_create result
dev_iter_create() may fail in malloc so check for its error code.
This commit is contained in:
parent
76936f2832
commit
22672be97d
@ -899,10 +899,13 @@ static int _insert_dir(const char *dir)
|
|||||||
|
|
||||||
static int _dev_cache_iterate_devs_for_index(struct cmd_context *cmd)
|
static int _dev_cache_iterate_devs_for_index(struct cmd_context *cmd)
|
||||||
{
|
{
|
||||||
struct dev_iter *iter = dev_iter_create(NULL, 0);
|
struct dev_iter *iter;
|
||||||
struct device *dev = NULL;
|
struct device *dev = NULL;
|
||||||
int r = 1;
|
int r = 1;
|
||||||
|
|
||||||
|
if (!(iter = dev_iter_create(NULL, 0)))
|
||||||
|
return_0;
|
||||||
|
|
||||||
while ((dev = dev_iter_get(NULL, iter)))
|
while ((dev = dev_iter_get(NULL, iter)))
|
||||||
if (!_index_dev_by_vgid_and_lvid(cmd, dev))
|
if (!_index_dev_by_vgid_and_lvid(cmd, dev))
|
||||||
r = 0;
|
r = 0;
|
||||||
@ -1786,9 +1789,12 @@ struct device *dev_cache_get_by_devt(struct cmd_context *cmd, dev_t devt)
|
|||||||
|
|
||||||
struct device *dev_cache_get_by_pvid(struct cmd_context *cmd, const char *pvid)
|
struct device *dev_cache_get_by_pvid(struct cmd_context *cmd, const char *pvid)
|
||||||
{
|
{
|
||||||
struct dev_iter *iter = dev_iter_create(NULL, 0);
|
struct dev_iter *iter;
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
|
|
||||||
|
if (!(iter = dev_iter_create(NULL, 0)))
|
||||||
|
return_NULL;
|
||||||
|
|
||||||
while ((dev = dev_iter_get(NULL, iter)))
|
while ((dev = dev_iter_get(NULL, iter)))
|
||||||
if (!memcmp(dev->pvid, pvid, ID_LEN))
|
if (!memcmp(dev->pvid, pvid, ID_LEN))
|
||||||
break;
|
break;
|
||||||
@ -1868,9 +1874,12 @@ const char *dev_name(const struct device *dev)
|
|||||||
bool dev_cache_has_md_with_end_superblock(struct dev_types *dt)
|
bool dev_cache_has_md_with_end_superblock(struct dev_types *dt)
|
||||||
{
|
{
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
struct dev_iter *iter = dev_iter_create(NULL, 0);
|
struct dev_iter *iter;
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
|
if (!(iter = dev_iter_create(NULL, 0)))
|
||||||
|
return_false;
|
||||||
|
|
||||||
while ((dev = dev_iter_get(NULL, iter)))
|
while ((dev = dev_iter_get(NULL, iter)))
|
||||||
if ((ret = dev_is_md_with_end_superblock(dt, dev)))
|
if ((ret = dev_is_md_with_end_superblock(dt, dev)))
|
||||||
break;
|
break;
|
||||||
|
@ -129,6 +129,7 @@
|
|||||||
|
|
||||||
#define return_0 do { stack; return 0; } while (0)
|
#define return_0 do { stack; return 0; } while (0)
|
||||||
#define return_NULL do { stack; return NULL; } while (0)
|
#define return_NULL do { stack; return NULL; } while (0)
|
||||||
|
#define return_false do { stack; return false; } while (0)
|
||||||
#define return_EINVALID_CMD_LINE \
|
#define return_EINVALID_CMD_LINE \
|
||||||
do { stack; return EINVALID_CMD_LINE; } while (0)
|
do { stack; return EINVALID_CMD_LINE; } while (0)
|
||||||
#define return_ECMD_FAILED do { stack; return ECMD_FAILED; } while (0)
|
#define return_ECMD_FAILED do { stack; return ECMD_FAILED; } while (0)
|
||||||
|
Loading…
Reference in New Issue
Block a user