diff --git a/src/fsck/fsck.c b/src/fsck/fsck.c index 524327c4da..8101f9ce95 100644 --- a/src/fsck/fsck.c +++ b/src/fsck/fsck.c @@ -265,6 +265,7 @@ static int fsck_progress_socket(void) { static int run(int argc, char *argv[]) { _cleanup_close_pair_ int progress_pipe[2] = { -1, -1 }; _cleanup_(sd_device_unrefp) sd_device *dev = NULL; + _cleanup_free_ char *dpath = NULL; const char *device, *type; bool root_directory; struct stat st; @@ -290,7 +291,11 @@ static int run(int argc, char *argv[]) { return 0; if (argc > 1) { - device = argv[1]; + dpath = strdup(argv[1]); + if (!dpath) + return log_oom(); + + device = dpath; if (stat(device, &st) < 0) return log_error_errno(errno, "Failed to stat %s: %m", device);