infiniband-diags: preserve long_opts global for use in ibdiag_show_usage
PATCH 1/1 infiniband-diags: preserve long_opts global for use in ibdiag_show_usage
Calling ibdiag_show_usage after ibdiag_process_opts will result in using free'd memory.
Signed-off-by Ira Weiny <[email protected]>
--- src/ibdiag_common.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-)
src/ibdiag_common.c +4 -3
@@ -74,7 +74,7 @@ uint32_t ibd_ibnetdisc_flags = IBND_CONFIG_MLX_EPI;static const char *prog_name;static const char *prog_args;static const char **prog_examples; -static struct option *long_opts; +static struct option *long_opts =NULL ;static const struct ibdiag_opt *opts_map[256 ];const static char *get_build_version (void )
@@ -357,6 +357,9 @@ int ibdiag_process_opts(int argc, char *const argv[], void *cxt, prog_args = usage_args; prog_examples = usage_examples; +if (long_opts) +free (long_opts); + long_opts =make_long_opts (exclude_common_str, custom_opts, opts_map);if (!long_opts)return -1 ;
@@ -380,8 +383,6 @@ int ibdiag_process_opts(int argc, char *const argv[], void *cxt,ibdiag_show_usage (); } -free (long_opts); -return 0 ; }
Signature · 6 lines
1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html