mirror of
git://sourceware.org/git/lvm2.git
synced 2024-10-03 17:50:03 +03:00
cov: extra pointer validation
Add few more internal errors to enusure there is no use of NULL pointers along the code path.
This commit is contained in:
parent
8545621d39
commit
3ce83f923d
@ -757,6 +757,11 @@ uint32_t dm_task_get_read_ahead(const struct dm_task *dmt, uint32_t *read_ahead)
|
||||
|
||||
struct dm_deps *dm_task_get_deps(struct dm_task *dmt)
|
||||
{
|
||||
if (!dmt) {
|
||||
log_error(INTERNAL_ERROR "Missing dm_task.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (struct dm_deps *) (((char *) dmt->dmi.v4) +
|
||||
dmt->dmi.v4->data_start);
|
||||
}
|
||||
|
@ -1453,9 +1453,14 @@ static void *_report_get_field_data(struct dm_report *rh,
|
||||
const struct dm_report_field_type *fields = fp->implicit ? _implicit_report_fields
|
||||
: rh->fields;
|
||||
|
||||
char *ret = fp->type->data_fn(object);
|
||||
char *ret;
|
||||
|
||||
if (!ret)
|
||||
if (!object) {
|
||||
log_error(INTERNAL_ERROR "_report_get_field_data: missing object.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(ret = fp->type->data_fn(object)))
|
||||
return NULL;
|
||||
|
||||
return (void *)(ret + fields[fp->field_num].offset);
|
||||
|
@ -3742,6 +3742,11 @@ uint32_t vg_bad_status_bits(const struct volume_group *vg, uint64_t status)
|
||||
{
|
||||
uint32_t failure = 0;
|
||||
|
||||
if (!vg) {
|
||||
log_error(INTERNAL_ERROR "Missing volume group.");
|
||||
return FAILED_NOTFOUND;
|
||||
}
|
||||
|
||||
if ((status & CLUSTERED) && !_access_vg_clustered(vg->cmd, vg))
|
||||
/* Return because other flags are considered undefined. */
|
||||
return FAILED_CLUSTERED;
|
||||
|
@ -765,6 +765,11 @@ uint32_t dm_task_get_read_ahead(const struct dm_task *dmt, uint32_t *read_ahead)
|
||||
|
||||
struct dm_deps *dm_task_get_deps(struct dm_task *dmt)
|
||||
{
|
||||
if (!dmt) {
|
||||
log_error(INTERNAL_ERROR "Missing dm_task.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (struct dm_deps *) (((char *) dmt->dmi.v4) +
|
||||
dmt->dmi.v4->data_start);
|
||||
}
|
||||
|
@ -1451,10 +1451,14 @@ static void *_report_get_field_data(struct dm_report *rh,
|
||||
{
|
||||
const struct dm_report_field_type *fields = fp->implicit ? _implicit_report_fields
|
||||
: rh->fields;
|
||||
char *ret;
|
||||
|
||||
char *ret = fp->type->data_fn(object);
|
||||
if (!object) {
|
||||
log_error(INTERNAL_ERROR "_report_get_field_data: missing object.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!ret)
|
||||
if (!(ret = fp->type->data_fn(object)))
|
||||
return NULL;
|
||||
|
||||
return (void *)(ret + fields[fp->field_num].offset);
|
||||
|
@ -618,6 +618,11 @@ static int _report_all_in_pv(struct cmd_context *cmd, struct processing_handle *
|
||||
{
|
||||
int r = ECMD_FAILED;
|
||||
|
||||
if (!pv) {
|
||||
log_error(INTERNAL_ERROR "_report_all_in_pv: missing pv.");
|
||||
return r;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case PVS:
|
||||
r = _pvs_single(cmd, pv->vg, pv, handle);
|
||||
|
Loading…
Reference in New Issue
Block a user