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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user