scsi_id: fix memory leak of option_get_synopsis() return value

option_get_synopsis() returns a heap-allocated string. Capture it in
a _cleanup_free_ variable so it is freed after being used in the log
message.

CID#1657828

Follow-up for 05fea7df1b
This commit is contained in:
Luca Boccassi
2026-05-05 13:55:00 +01:00
parent a3f75ace9c
commit 83436d4b7e
+5 -2
View File
@@ -328,10 +328,13 @@ static int per_dev_options(struct scsi_id_device *dev_scsi, int *good_bad, enum
r = parse_page_code(opts.arg, page_code);
if (r < 0)
return r;
} else
} else {
_cleanup_free_ char *synopsis =
option_get_synopsis(opts.opt, "/", /* show_metavar=*/ false);
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"Option %s not supported in the config file.",
strnull(option_get_synopsis(opts.opt, "/", /* show_metavar=*/ false)));
strnull(synopsis));
}
return 0;
}