Skip to content

Commit a5715af

Browse files
committed
coredump: make coredump_parse() return bool
There's no point in returning negative error values. They will never be seen by anyone. Link: https://lore.kernel.org/20250612-work-coredump-massage-v1-2-315c0c34ba94@kernel.org Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent fb4366b commit a5715af

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

fs/coredump.c

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,8 @@ static int cn_print_exe_file(struct core_name *cn, bool name_only)
230230
* into corename, which must have space for at least CORENAME_MAX_SIZE
231231
* bytes plus one byte for the zero terminator.
232232
*/
233-
static int coredump_parse(struct core_name *cn, struct coredump_params *cprm,
234-
size_t **argv, int *argc)
233+
static bool coredump_parse(struct core_name *cn, struct coredump_params *cprm,
234+
size_t **argv, int *argc)
235235
{
236236
const struct cred *cred = current_cred();
237237
const char *pat_ptr = core_pattern;
@@ -251,49 +251,49 @@ static int coredump_parse(struct core_name *cn, struct coredump_params *cprm,
251251
else
252252
cn->core_type = COREDUMP_FILE;
253253
if (expand_corename(cn, core_name_size))
254-
return -ENOMEM;
254+
return false;
255255
cn->corename[0] = '\0';
256256

257257
switch (cn->core_type) {
258258
case COREDUMP_PIPE: {
259259
int argvs = sizeof(core_pattern) / 2;
260260
(*argv) = kmalloc_array(argvs, sizeof(**argv), GFP_KERNEL);
261261
if (!(*argv))
262-
return -ENOMEM;
262+
return false;
263263
(*argv)[(*argc)++] = 0;
264264
++pat_ptr;
265265
if (!(*pat_ptr))
266-
return -ENOMEM;
266+
return false;
267267
break;
268268
}
269269
case COREDUMP_SOCK: {
270270
/* skip the @ */
271271
pat_ptr++;
272272
if (!(*pat_ptr))
273-
return -ENOMEM;
273+
return false;
274274
if (*pat_ptr == '@') {
275275
pat_ptr++;
276276
if (!(*pat_ptr))
277-
return -ENOMEM;
277+
return false;
278278

279279
cn->core_type = COREDUMP_SOCK_REQ;
280280
}
281281

282282
err = cn_printf(cn, "%s", pat_ptr);
283283
if (err)
284-
return err;
284+
return false;
285285

286286
/* Require absolute paths. */
287287
if (cn->corename[0] != '/')
288-
return -EINVAL;
288+
return false;
289289

290290
/*
291291
* Ensure we can uses spaces to indicate additional
292292
* parameters in the future.
293293
*/
294294
if (strchr(cn->corename, ' ')) {
295295
coredump_report_failure("Coredump socket may not %s contain spaces", cn->corename);
296-
return -EINVAL;
296+
return false;
297297
}
298298

299299
/*
@@ -303,13 +303,13 @@ static int coredump_parse(struct core_name *cn, struct coredump_params *cprm,
303303
* via /proc/<pid>, using the SO_PEERPIDFD to guard
304304
* against pid recycling when opening /proc/<pid>.
305305
*/
306-
return 0;
306+
return true;
307307
}
308308
case COREDUMP_FILE:
309309
break;
310310
default:
311311
WARN_ON_ONCE(true);
312-
return -EINVAL;
312+
return false;
313313
}
314314

315315
/* Repeat as long as we have more pattern to process and more output
@@ -447,7 +447,7 @@ static int coredump_parse(struct core_name *cn, struct coredump_params *cprm,
447447
}
448448

449449
if (err)
450-
return err;
450+
return false;
451451
}
452452

453453
out:
@@ -457,9 +457,9 @@ static int coredump_parse(struct core_name *cn, struct coredump_params *cprm,
457457
* and core_uses_pid is set, then .%pid will be appended to
458458
* the filename. Do not do this for piped commands. */
459459
if (cn->core_type == COREDUMP_FILE && !pid_in_pattern && core_uses_pid)
460-
return cn_printf(cn, ".%d", task_tgid_vnr(current));
460+
return cn_printf(cn, ".%d", task_tgid_vnr(current)) == 0;
461461

462-
return 0;
462+
return true;
463463
}
464464

465465
static int zap_process(struct signal_struct *signal, int exit_code)
@@ -911,8 +911,7 @@ void do_coredump(const kernel_siginfo_t *siginfo)
911911

912912
old_cred = override_creds(cred);
913913

914-
retval = coredump_parse(&cn, &cprm, &argv, &argc);
915-
if (retval < 0) {
914+
if (!coredump_parse(&cn, &cprm, &argv, &argc)) {
916915
coredump_report_failure("format_corename failed, aborting core");
917916
goto fail_unlock;
918917
}

0 commit comments

Comments
 (0)