diff options
author | Toomas Soome <tsoome@me.com> | 2020-04-11 00:51:25 +0300 |
---|---|---|
committer | Toomas Soome <tsoome@me.com> | 2020-06-12 18:08:36 +0300 |
commit | 926d645fe2416b8ee611fc8ee4e28b7c7f9744dd (patch) | |
tree | 6245691cbdd97c1c3c3a3f1c054b7a8d690da24f | |
parent | 7fa359c09493c7b56e7c3e98fccc7e5cc0f09b48 (diff) | |
download | illumos-joyent-926d645fe2416b8ee611fc8ee4e28b7c7f9744dd.tar.gz |
12531 storage: NULL pointer errors
Reviewed by: Patrick Mooney <pmooney@pfmooney.com>
Approved by: Robert Mustacchi <rm@fingolfin.org>
-rw-r--r-- | usr/src/lib/storage/liba5k/common/lhot.c | 19 | ||||
-rw-r--r-- | usr/src/lib/storage/liba5k/common/mon.c | 74 | ||||
-rw-r--r-- | usr/src/lib/storage/libg_fc/common/io.c | 6 | ||||
-rw-r--r-- | usr/src/lib/storage/libg_fc/common/map.c | 76 | ||||
-rw-r--r-- | usr/src/lib/storage/libg_fc/common/mpath.c | 18 |
5 files changed, 95 insertions, 98 deletions
diff --git a/usr/src/lib/storage/liba5k/common/lhot.c b/usr/src/lib/storage/liba5k/common/lhot.c index ab8115f5a5..eca51e31dd 100644 --- a/usr/src/lib/storage/liba5k/common/lhot.c +++ b/usr/src/lib/storage/liba5k/common/lhot.c @@ -318,7 +318,7 @@ Box_list *boxlist; if (((ptr = strstr(boxname, ",")) != NULL) && ((*(ptr + 1) == 'f') || (*(ptr + 1) == 'r') || (*(ptr + 1) == 's'))) { - *ptr = NULL; + *ptr = '\0'; } else { return (0); } @@ -332,7 +332,7 @@ Box_list *boxlist; return (L_NO_ENCL_LIST_FOUND); } - *ses_path = NULL; + *ses_path = '\0'; /* * The following method is safer to get an ses path @@ -397,13 +397,12 @@ Box_list *boxlist; */ int l_encl_status_page_funcs(int func, char *code, int todo, char *ses_path, - struct l_state_struct *l_state, - int f_flag, int slot, int verbose_flag) + struct l_state_struct *l_state, int f_flag, int slot, int verbose_flag) { -uchar_t *page_buf; -int fd, front_index, rear_index, offset, err; -unsigned short page_len; -struct device_element *elem; + uchar_t *page_buf; + int fd, front_index, rear_index, offset, err; + unsigned short page_len; + struct device_element *elem; if ((ses_path == NULL) || (l_state == NULL)) { return (L_INVALID_PATH_FORMAT); @@ -885,7 +884,7 @@ Path_struct *p_pathstruct; free(p_pathstruct); switch (enc_type) { case DAK_ENC_TYPE: - if (f_flag != NULL) { + if (f_flag != 0) { (void) sprintf(drive_name, MSGSTR(8502, "Drive in \"%s\" slot %d"), box_name, slot); } else { @@ -895,7 +894,7 @@ Path_struct *p_pathstruct; } break; default: - if (f_flag != NULL) { + if (f_flag != 0) { (void) sprintf(drive_name, MSGSTR(8500, "Drive in \"%s\" front slot %d"), box_name, slot); } else { diff --git a/usr/src/lib/storage/liba5k/common/mon.c b/usr/src/lib/storage/liba5k/common/mon.c index 535a65cf99..26e93674ca 100644 --- a/usr/src/lib/storage/liba5k/common/mon.c +++ b/usr/src/lib/storage/liba5k/common/mon.c @@ -64,7 +64,7 @@ #include <a5k.h> -/* Defines */ +/* Defines */ #define PLNDEF "SUNW,pln" /* check if box name starts with 'c' */ #define DOWNLOAD_RETRIES 60*5 /* 5 minutes */ #define IBFIRMWARE_FILE "/usr/lib/locale/C/LC_MESSAGES/ibfirmware" @@ -519,17 +519,16 @@ int i, rear_flag = 0; */ int l_led(struct path_struct *path_struct, int led_action, - struct device_element *status, - int verbose) + struct device_element *status, int verbose) { -gfc_map_t map; -char ses_path[MAXPATHLEN]; -uchar_t *page_buf; -int err, write, fd, front_index, rear_index, offset; -unsigned short page_len; -struct device_element *elem; -L_state *l_state; -int enc_type; + gfc_map_t map; + char ses_path[MAXPATHLEN]; + uchar_t *page_buf; + int err, write, fd, front_index, rear_index, offset; + unsigned short page_len; + struct device_element *elem; + L_state *l_state; + int enc_type; if ((path_struct == NULL) || (status == NULL)) { return (L_INVALID_PATH_FORMAT); @@ -1184,14 +1183,15 @@ pwr_up_dwn: */ static int pwr_up_down(char *path_phys, L_state *l_state, int front, int slot, - int power_off_flag, int verbose) + int power_off_flag, int verbose) { -L_inquiry inq; -int fd, status, err; -uchar_t *page_buf; -int front_index, rear_index, front_offset, rear_offset; -unsigned short page_len; -struct device_element *front_elem, *rear_elem; + L_inquiry inq; + int fd, status, err; + uchar_t *page_buf; + int front_index, rear_index, front_offset; + int rear_offset; + unsigned short page_len; + struct device_element *front_elem, *rear_elem; (void) memset(&inq, 0, sizeof (inq)); if ((fd = g_object_open(path_phys, O_NDELAY | O_RDONLY)) == -1) { @@ -1561,7 +1561,7 @@ int al_pa; /* Get the port WWN from the IB, page 1 */ if ((status = l_get_envsen_page(fd, (uchar_t *)&page1, - sizeof (page1), 1, 0)) != NULL) { + sizeof (page1), 1, 0)) != 0) { (void) close(fd); g_destroy_data(result); (void) g_destroy_data(dev_name); @@ -1606,7 +1606,7 @@ int al_pa; (char *)inq.inq_box_name, sizeof (inq.inq_box_name)); /* make sure null terminated */ - l2->b_name[sizeof (l2->b_name) - 1] = NULL; + l2->b_name[sizeof (l2->b_name) - 1] = '\0'; /* * Now get the port WWN for the port @@ -1807,7 +1807,7 @@ load_flds_if_enc_disk(char *phys_path, struct path_struct **path_struct) L_state *l_state = NULL; if ((path_struct == NULL) || (*path_struct == NULL) || - (phys_path == NULL) || (*phys_path == NULL)) { + (phys_path == NULL) || (*phys_path == '\0')) { return (L_INVALID_PATH_FORMAT); } @@ -2073,7 +2073,7 @@ WWN_list *wwn_list, *wwn_list_ptr; if (((char_ptr = strstr(tmp_name, ",")) != NULL) && ((*(char_ptr + 1) == 'f') || (*(char_ptr + 1) == 'r') || (*(char_ptr + 1) == 's'))) { - *char_ptr = NULL; /* make just box name */ + *char_ptr = '\0'; /* make just box name */ found_comma = 1; } /* Find path to IB */ @@ -2398,7 +2398,7 @@ ushort_t num_pages; /* Get page 0 */ if ((rval = l_get_envsen_page(fd, local_buf_ptr, - size, page_code, verbose)) != NULL) { + size, page_code, verbose)) != 0) { (void) close(fd); return (rval); } @@ -2447,7 +2447,7 @@ ushort_t num_pages; page_code = *page_list_ptr; if ((rval = l_get_envsen_page(fd, local_buf_ptr, - size, page_code, verbose)) != NULL) { + size, page_code, verbose)) != 0) { (void) close(fd); return (rval); } @@ -2500,7 +2500,7 @@ struct stat sbuf; } /* Initialize */ - *path_a = *path_b = NULL; + *path_a = *path_b = '\0'; l_disk_state->g_disk_state.num_blocks = 0; /* Get paths. */ @@ -2699,7 +2699,7 @@ Read_reserv read_reserv_buf; MSGSTR(9048, " Checking for Persistent " "Reservations:")); if (l_disk_state->g_disk_state.persistent_reserv_flag) { - if (l_disk_state->g_disk_state.persistent_active != NULL) { + if (l_disk_state->g_disk_state.persistent_active != 0) { (void) fprintf(stdout, MSGSTR(39, "Active")); } else { (void) fprintf(stdout, MSGSTR(9049, "Registered")); @@ -3717,7 +3717,6 @@ hrtime_t start_time, end_time; if ((strcmp(seslist->dev_path, path) != 0) && !port_a_flag) { - *path = NULL; (void) strcpy(path, seslist->dev_path); if (err = @@ -3742,7 +3741,6 @@ hrtime_t start_time, end_time; } if ((strcmp(seslist->dev_path, path) != 0) && port_a_flag) { - *path = NULL; (void) strcpy(path, seslist->dev_path); if (err = @@ -4310,7 +4308,7 @@ int status, sz; static int dak_download_code_cmd(int fd, uchar_t *buf_ptr, int buf_len) { - int status = 0; + int status = 0; int sz = 0; int offs = 0; @@ -4334,10 +4332,10 @@ dak_download_code_cmd(int fd, uchar_t *buf_ptr, int buf_len) * Downloads the new prom image to IB. * * INPUTS: - * path - physical path of Photon SES card - * file - input file for new code (may be NULL) - * ps - whether the "save" bit should be set - * verbose - to be verbose or not + * path - physical path of Photon SES card + * file - input file for new code (may be NULL) + * ps - whether the "save" bit should be set + * verbose - to be verbose or not * * RETURNS: * 0 O.K. @@ -4954,11 +4952,11 @@ l_element_msg_string(uchar_t code, char *es) */ int l_get_allses(char *path, struct box_list_struct *box_list, - struct dlist **ses_list, int verbose) + struct dlist **ses_list, int verbose) { -struct box_list_struct *box_list_ptr; -char node_wwn_s[WWN_S_LEN]; -struct dlist *dlt, *dl; + struct box_list_struct *box_list_ptr; + char node_wwn_s[WWN_S_LEN]; + struct dlist *dlt, *dl; if ((path == NULL) || (box_list == NULL) || (ses_list == NULL)) { return (L_INVALID_PATH_FORMAT); @@ -5044,7 +5042,7 @@ l_get_enc_type(L_inquiry inq) } /* * ADD OTHERS here if ever needed/wanted, and add to def's - * as noted above + * as noted above */ return (UNDEF_ENC_TYPE); } diff --git a/usr/src/lib/storage/libg_fc/common/io.c b/usr/src/lib/storage/libg_fc/common/io.c index 59a560079c..024fc32520 100644 --- a/usr/src/lib/storage/libg_fc/common/io.c +++ b/usr/src/lib/storage/libg_fc/common/io.c @@ -682,7 +682,7 @@ struct scsi_extended_sense sense; ucmd.uscsi_cdb = (caddr_t)&cdb; ucmd.uscsi_cdblen = CDB_GROUP0; ucmd.uscsi_bufaddr = NULL; - ucmd.uscsi_buflen = NULL; + ucmd.uscsi_buflen = 0; ucmd.uscsi_rqbuf = (caddr_t)&sense; ucmd.uscsi_rqlen = sizeof (struct scsi_extended_sense); ucmd.uscsi_timeout = 60; @@ -706,9 +706,9 @@ int err; (void) memset((char *)&ucmd, 0, sizeof (ucmd)); ucmd.uscsi_cdb = NULL; - ucmd.uscsi_cdblen = NULL; + ucmd.uscsi_cdblen = 0; ucmd.uscsi_bufaddr = NULL; - ucmd.uscsi_buflen = NULL; + ucmd.uscsi_buflen = 0; ucmd.uscsi_rqbuf = (caddr_t)&sense; ucmd.uscsi_rqlen = sizeof (struct scsi_extended_sense); ucmd.uscsi_timeout = 60; diff --git a/usr/src/lib/storage/libg_fc/common/map.c b/usr/src/lib/storage/libg_fc/common/map.c index f685f2eb25..9941ebba3d 100644 --- a/usr/src/lib/storage/libg_fc/common/map.c +++ b/usr/src/lib/storage/libg_fc/common/map.c @@ -113,8 +113,8 @@ typedef struct impl_map_dev_prop { char prop_name[MAXNAMELEN]; int prop_type; int prop_size; - void *prop_data; - int prop_error; + void *prop_data; + int prop_error; struct impl_map_dev_prop *next; } impl_map_dev_prop_t; @@ -124,10 +124,10 @@ typedef struct impl_map_dev { impl_map_dev_prop_t *prop_list; struct impl_map_dev *parent; struct impl_map_dev *child; - struct impl_map_dev *next; + struct impl_map_dev *next; } impl_map_dev_t; -/* Defines */ +/* Defines */ #define VERBPRINT if (verbose) (void) printf #define DIR_MATCH_ST "*[0-9+]n" @@ -732,7 +732,8 @@ g_devices_get_all(struct wwn_list_struct **wwn_list_ptr) } void -g_free_wwn_list_found(struct wwn_list_found_struct **wwn_list_found) { +g_free_wwn_list_found(struct wwn_list_found_struct **wwn_list_found) +{ WWN_list_found *next = NULL; /* return if wwn_list_found is NULL */ @@ -1065,7 +1066,7 @@ g_issue_fcio_ioctl(int fd, fcio_t *fcio, int verbose) static int g_issue_fcp_ioctl(int fd, struct fcp_ioctl *fcp_data, int verbose) { - int num_tries = 0; + int num_tries = 0; struct device_data *dev_data = NULL; /* @@ -1711,7 +1712,7 @@ create_map(char *path, gfc_map_t *map_ptr, int verbose, int map_type) if (map_type == MAP_FORMAT_LILP && num_devices > 0) { /* First we need to allocate one additional */ - /* device to the dev_addr structure, for the */ + /* device to the dev_addr structure, for the */ /* local hba */ if ((dev_list = (fc_port_dev_t *)realloc(dev_list, (num_devices * sizeof (fc_port_dev_t)))) @@ -2076,7 +2077,7 @@ handle_map_dev_FCP_prop(minor_t fp_xport_minor, la_wwn_t port_wwn, impl_map_dev_prop_t **prop_list) { struct device_data inq_data; - int fcp_fd, err; + int fcp_fd, err; struct fcp_ioctl fcp_data; uchar_t inq_dtype; @@ -2410,7 +2411,7 @@ g_dev_map_init(char *path, int *l_err, int flag) /* dev_addr array so it's in physical order. */ if ((flag & MAP_FORMAT_LILP) == MAP_FORMAT_LILP) { /* First we need to allocate one additional */ - /* device to the dev_addr structure, for the */ + /* device to the dev_addr structure, for the */ /* local hba */ if (num_devices > 0) { if ((dev_list = (fc_port_dev_t *) @@ -3752,7 +3753,7 @@ get_wwns(char *path_phys, uchar_t port_wwn[], uchar_t node_wwn[], int *al_pa, int i, err, count; char *char_ptr, *ptr; int found = 0, pathcnt, *port_addr; - unsigned long long pwwn; + unsigned long long pwwn; uchar_t *port_wwn_byte, *node_wwn_byte; char drvr_path[MAXPATHLEN]; int p_on = 0, p_st = 0; @@ -4138,7 +4139,7 @@ g_stop(char *path, int immediate_flag) int g_reserve(char *path) { - int fd, status; + int fd, status; P_DPRINTF(" g_reserve: Reserve: Path %s\n", path); if ((fd = g_object_open(path, O_NDELAY | O_RDONLY)) == -1) @@ -4151,7 +4152,7 @@ g_reserve(char *path) int g_release(char *path) { - int fd, status; + int fd, status; P_DPRINTF(" g_release: Release: Path %s\n", path); if ((fd = g_object_open(path, O_NDELAY | O_RDONLY)) == -1) @@ -4423,7 +4424,7 @@ get_multipath_disk(char *devpath, struct dlist **multipath_list, int get_multipath(char *devpath, struct dlist **multipath_list, - struct wwn_list_struct *wwn_list) + struct wwn_list_struct *wwn_list) { WWN_list *wwn_list_ptr; struct dlist *dl, *dlt; @@ -4452,7 +4453,8 @@ get_multipath(char *devpath, struct dlist **multipath_list, return (L_NULL_WWN_LIST); } - for (*node_wwn_s = NULL, wwn_list_ptr = wwn_list; + *node_wwn_s = '\0'; + for (wwn_list_ptr = wwn_list; wwn_list_ptr != NULL; wwn_list_ptr = wwn_list_ptr->wwn_next) { @@ -4471,8 +4473,8 @@ get_multipath(char *devpath, struct dlist **multipath_list, } } - if (*node_wwn_s == NULL) { - H_DPRINTF("node_wwn_s is NULL!\n"); + if (*node_wwn_s == '\0') { + H_DPRINTF("node_wwn_s is not found!\n"); return (L_NO_NODE_WWN_IN_WWNLIST); } @@ -4716,7 +4718,7 @@ g_get_nexus_path(char *path_phys, char **nexus_path) * The routine calls g_get_path_type to determine the stack of * the input path. * - * If it a socal path + * If it a socal path * it returns FC_TOP_PRIVATE_LOOP * else * calls fc_get_topology ioctl to @@ -4734,29 +4736,29 @@ g_get_nexus_path(char *path_phys, char **nexus_path) * error code. * * The input path is expected to be something like below: - * 1) - * /devices/sbus@1f,0/SUNW,socal@1,0/SUNW,sf@0,0/ses@e,0:0 - * /devices/sbus@1f,0/SUNW,socal@1,0/SUNW,sf@0,0/ssd@.. - * /devices/sbus@1f,0/SUNW,socal@1,0/SUNW,sf@1,0 - * /devices/sbus@1f,0/SUNW,socal@1,0 - * /devices/sbus@1f,0/SUNW,socal@1,0:1 - * /devices/sbus@1f,0/SUNW,socal@1,0/SUNW,sf@0,0:devctl - * (or "qlc" instead of "socal" and "fp" for "sf") + * 1) + * /devices/sbus@1f,0/SUNW,socal@1,0/SUNW,sf@0,0/ses@e,0:0 + * /devices/sbus@1f,0/SUNW,socal@1,0/SUNW,sf@0,0/ssd@.. + * /devices/sbus@1f,0/SUNW,socal@1,0/SUNW,sf@1,0 + * /devices/sbus@1f,0/SUNW,socal@1,0 + * /devices/sbus@1f,0/SUNW,socal@1,0:1 + * /devices/sbus@1f,0/SUNW,socal@1,0/SUNW,sf@0,0:devctl + * (or "qlc" instead of "socal" and "fp" for "sf") * - * Which should resolve to a path like this: - * /devices/sbus@1f,0/SUNW,socal@1,0:1 - * /devices/pci@6,2000/pci@2/SUNW,qlc@5 + * Which should resolve to a path like this: + * /devices/sbus@1f,0/SUNW,socal@1,0:1 + * /devices/pci@6,2000/pci@2/SUNW,qlc@5 * - * 2) - * /devices/pci@4,2000/scsi@1/ses@w50800200000000d2,0:0 - * which should resolve to - * /devices/pci@4,2000/scsi@1:devctl + * 2) + * /devices/pci@4,2000/scsi@1/ses@w50800200000000d2,0:0 + * which should resolve to + * /devices/pci@4,2000/scsi@1:devctl * - * 3) The nexus(hba or nexus) path will get an error only for qlc + * 3) The nexus(hba or nexus) path will get an error only for qlc * since the routine need to open fp :devctl node for fcio ioctl. - * /devices/sbus@1f,0/SUNW,socal@1,0 - * /devices/sbus@1f,0/SUNW,socal@1,0:1 - * /devices/pci@6,2000/pci@2/SUNW,qlc@5 => error + * /devices/sbus@1f,0/SUNW,socal@1,0 + * /devices/sbus@1f,0/SUNW,socal@1,0:1 + * /devices/pci@6,2000/pci@2/SUNW,qlc@5 => error */ int g_get_fca_port_topology(char *path, uint32_t *port_top, int verbose) @@ -4989,7 +4991,7 @@ g_port_online(char *path) * INPUTS : * portpath - Pointer to the path of the FCA port on which to * set the loopback mode - * cmd - EXT_LPBACK + * cmd - EXT_LPBACK * INT_LPBACK * NO_LPBACK * RETURNS : diff --git a/usr/src/lib/storage/libg_fc/common/mpath.c b/usr/src/lib/storage/libg_fc/common/mpath.c index dd354a9ce9..f76fa80a85 100644 --- a/usr/src/lib/storage/libg_fc/common/mpath.c +++ b/usr/src/lib/storage/libg_fc/common/mpath.c @@ -235,19 +235,17 @@ get_pathlist(char *dev_path, sv_iocdata_t *ioc, int *num_paths_to_copy) int fd; int initial_path_count; int current_path_count; - int i; + int i; char *delimiter; int malloc_error = 0; - int prop_buf_size; + int prop_buf_size; int pathlist_retry_count = 0; - if (strncmp(dev_path, SCSI_VHCI, - strlen(SCSI_VHCI)) != NULL) { + if (strncmp(dev_path, SCSI_VHCI, strlen(SCSI_VHCI)) != 0) { if ((physical_path = g_get_physical_name(dev_path)) == NULL) { return (L_INVALID_PATH); } - if (strncmp(physical_path, SCSI_VHCI, - strlen(SCSI_VHCI)) != NULL) { + if (strncmp(physical_path, SCSI_VHCI, strlen(SCSI_VHCI)) != 0) { free(physical_path); return (L_INVALID_PATH); } @@ -265,7 +263,7 @@ get_pathlist(char *dev_path, sv_iocdata_t *ioc, int *num_paths_to_copy) delimiter = strrchr(physical_path, ':'); /* if we didn't find the ':' fine, else truncate */ if (delimiter != NULL) { - *delimiter = NULL; + *delimiter = '\0'; } /* @@ -388,7 +386,7 @@ return (0); * dev_path client device path * example: /devices/scsi_vhci/ssd@g280000602200416d6257333030303261:c,raw * outputs: - * pathlist_p pathlist structure containing pathinfo node data + * pathlist_p pathlist structure containing pathinfo node data * returns: * 0 - success * !0 - failure @@ -400,8 +398,8 @@ g_get_pathlist(char *dev_path, struct mp_pathlist *pathlist_p) sv_iocdata_t ioc; int retval, caller_ret = 0; int num_paths_to_copy; - int i; - int prop_buf_size; + int i; + int prop_buf_size; char *path_class_val = NULL; char *temp_addr; char phci_path[MAXPATHLEN]; |