1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

cleanup: validate pointers

Mostly on almost impossible to happen paths - but stay safe.
This commit is contained in:
Zdenek Kabelac 2014-11-13 17:40:30 +01:00
parent 7278556c76
commit 428b9fcd87
4 changed files with 16 additions and 6 deletions

View File

@ -131,7 +131,8 @@ static int _get_segment_status_from_target_params(const char *target_name,
if (strcmp(target_name, "cache")) if (strcmp(target_name, "cache"))
return 1; return 1;
segtype = get_segtype_from_string(seg_status->seg->lv->vg->cmd, target_name); if (!(segtype = get_segtype_from_string(seg_status->seg->lv->vg->cmd, target_name)))
return_0;
if (segtype != seg_status->seg->segtype) { if (segtype != seg_status->seg->segtype) {
log_error(INTERNAL_ERROR "_get_segment_status_from_target_params: " log_error(INTERNAL_ERROR "_get_segment_status_from_target_params: "

View File

@ -779,7 +779,9 @@ static int _cachemode_disp(struct dm_report *rh, struct dm_pool *mem,
seg = first_seg(seg->pool_lv); seg = first_seg(seg->pool_lv);
if (seg_is_cache_pool(seg)) { if (seg_is_cache_pool(seg)) {
cachemode_str = get_cache_pool_cachemode_name(seg); if (!(cachemode_str = get_cache_pool_cachemode_name(seg)))
return_0;
return dm_report_field_string(rh, field, &cachemode_str); return dm_report_field_string(rh, field, &cachemode_str);
} }

View File

@ -3824,13 +3824,15 @@ int main(int argc, char **argv)
} }
if (_switches[HELP_ARG]) { if (_switches[HELP_ARG]) {
cmd = _find_command("help"); if ((cmd = _find_command("help")))
goto doit; goto doit;
goto unknown;
} }
if (_switches[VERSION_ARG]) { if (_switches[VERSION_ARG]) {
cmd = _find_command("version"); if ((cmd = _find_command("version")))
goto doit; goto doit;
goto unknown;
} }
if (argc == 0) { if (argc == 0) {
@ -3839,6 +3841,7 @@ int main(int argc, char **argv)
} }
if (!(cmd = _find_command(argv[0]))) { if (!(cmd = _find_command(argv[0]))) {
unknown:
fprintf(stderr, "Unknown command\n"); fprintf(stderr, "Unknown command\n");
_usage(stderr); _usage(stderr);
goto out; goto out;

View File

@ -30,6 +30,10 @@ static int _pvresize_single(struct cmd_context *cmd,
{ {
struct pvresize_params *params = (struct pvresize_params *) handle; struct pvresize_params *params = (struct pvresize_params *) handle;
if (!params) {
log_error(INTERNAL_ERROR "Invalid resize params.");
return ECMD_FAILED;
}
params->total++; params->total++;
if (!pv_resize_single(cmd, vg, pv, params->new_size)) if (!pv_resize_single(cmd, vg, pv, params->new_size))