From: Nathan F. <nf...@li...> - 2014-11-18 19:57:56
|
In response to my earlier patch that attempted to correct the -s option handling for drmgr I introduced a bug in which the usr_drc_name could be NULL causing a segfault when attempting to use it. This patch adds a check to make sure it is not NULL. Signed-off-by: Nathan Fontenot <nf...@li...> --- src/drmgr/drslot_chrp_cpu.c | 2 +- src/drmgr/drslot_chrp_mem.c | 2 +- src/drmgr/drslot_chrp_pci.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/drmgr/drslot_chrp_cpu.c b/src/drmgr/drslot_chrp_cpu.c index f45b9ed..e6f185d 100644 --- a/src/drmgr/drslot_chrp_cpu.c +++ b/src/drmgr/drslot_chrp_cpu.c @@ -312,7 +312,7 @@ valid_cpu_options(struct options *opts) } /* The -s option can specify a drc name or drc index */ - if (!strncmp(opts->usr_drc_name, "0x", 2)) { + if (opts->usr_drc_name && !strncmp(opts->usr_drc_name, "0x", 2)) { opts->usr_drc_index = strtoul(opts->usr_drc_name, NULL, 16); opts->usr_drc_name = NULL; } diff --git a/src/drmgr/drslot_chrp_mem.c b/src/drmgr/drslot_chrp_mem.c index a867894..d6ece97 100644 --- a/src/drmgr/drslot_chrp_mem.c +++ b/src/drmgr/drslot_chrp_mem.c @@ -1221,7 +1221,7 @@ valid_mem_options(struct options *opts) } /* The -s option can specify a drc name or drc index */ - if (!strncmp(opts->usr_drc_name, "0x", 2)) { + if (opts->usr_drc_name && !strncmp(opts->usr_drc_name, "0x", 2)) { opts->usr_drc_index = strtoul(opts->usr_drc_name, NULL, 16); opts->usr_drc_name = NULL; } diff --git a/src/drmgr/drslot_chrp_pci.c b/src/drmgr/drslot_chrp_pci.c index 2164363..0c8de2f 100644 --- a/src/drmgr/drslot_chrp_pci.c +++ b/src/drmgr/drslot_chrp_pci.c @@ -844,7 +844,7 @@ valid_pci_options(struct options *opts) } /* The -s option can specify a drc name or drc index */ - if (!strncmp(opts->usr_drc_name, "0x", 2)) { + if (opts->usr_drc_name && !strncmp(opts->usr_drc_name, "0x", 2)) { opts->usr_drc_index = strtoul(opts->usr_drc_name, NULL, 16); opts->usr_drc_name = NULL; } |