Skip to content

Commit

Permalink
hibernate-resume: refuse resume if resume_offset= is set but not resume=
Browse files Browse the repository at this point in the history
  • Loading branch information
YHNdnzj authored and bluca committed Jul 9, 2023
1 parent 906682a commit c089af8
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/hibernate-resume/hibernate-resume-generator.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ static char *arg_resume_options = NULL;
static char *arg_root_options = NULL;
static bool arg_noresume = false;
static uint64_t arg_resume_offset = 0;
static bool arg_resume_offset_set = false;

STATIC_DESTRUCTOR_REGISTER(arg_resume_device, freep);
STATIC_DESTRUCTOR_REGISTER(arg_resume_options, freep);
Expand Down Expand Up @@ -73,6 +74,8 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
if (r < 0)
return log_error_errno(r, "Failed to parse resume_offset=%s: %m", value);

arg_resume_offset_set = true;

} else if (proc_cmdline_key_streq(key, "resumeflags")) {

if (proc_cmdline_value_missing(key, value))
Expand Down Expand Up @@ -263,6 +266,11 @@ static int run(const char *dest, const char *dest_early, const char *dest_late)
return 0;
}

if (!arg_resume_device && arg_resume_offset_set)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"Found resume_offset=%" PRIu64 " but resume= is unset, refusing.",
arg_resume_offset);

r = parse_efi_hibernate_location();
if (r == -ENOMEM)
return r;
Expand Down

0 comments on commit c089af8

Please sign in to comment.