Print this page
10324 topo_usb_parse_port_type() gets value check wrong


 273                 topo_mod_dprintf(mod, "failed to duplicate label for port");
 274                 return (B_FALSE);
 275         }
 276 
 277         parse->tp_state = TOPO_USB_P_PORT;
 278 
 279         return (B_TRUE);
 280 }
 281 
 282 static boolean_t
 283 topo_usb_parse_port_type(topo_mod_t *mod, topo_usb_parse_t *parse,
 284     const char *line)
 285 {
 286         unsigned long val;
 287         char *eptr;
 288 
 289         VERIFY3S(parse->tp_state, ==, TOPO_USB_P_PORT_TYPE);
 290 
 291         errno = 0;
 292         val = strtoul(line, &eptr, 0);
 293         if (errno != 0 || *eptr != '\0' || val > UINT_MAX) {
 294                 topo_mod_dprintf(mod, "encountered bad value for port-type "
 295                     "line: %s", line);
 296                 return (B_FALSE);
 297         }
 298 
 299         parse->tp_cport->tmp_port_type = (uint_t)val;
 300 
 301         parse->tp_state = TOPO_USB_P_PORT;
 302         return (B_TRUE);
 303 }
 304 
 305 static boolean_t
 306 topo_usb_parse_path(topo_mod_t *mod, topo_usb_parse_t *parse,
 307     topo_usb_path_type_t ptype, const char *line)
 308 {
 309         char *fspath;
 310         topo_usb_meta_port_path_t *path;
 311 
 312         VERIFY(parse->tp_state == TOPO_USB_P_ACPI_PATH);
 313         VERIFY3P(parse->tp_cport, !=, NULL);




 273                 topo_mod_dprintf(mod, "failed to duplicate label for port");
 274                 return (B_FALSE);
 275         }
 276 
 277         parse->tp_state = TOPO_USB_P_PORT;
 278 
 279         return (B_TRUE);
 280 }
 281 
 282 static boolean_t
 283 topo_usb_parse_port_type(topo_mod_t *mod, topo_usb_parse_t *parse,
 284     const char *line)
 285 {
 286         unsigned long val;
 287         char *eptr;
 288 
 289         VERIFY3S(parse->tp_state, ==, TOPO_USB_P_PORT_TYPE);
 290 
 291         errno = 0;
 292         val = strtoul(line, &eptr, 0);
 293         if (errno != 0 || *eptr != '\0' || val >= UINT_MAX) {
 294                 topo_mod_dprintf(mod, "encountered bad value for port-type "
 295                     "line: %s", line);
 296                 return (B_FALSE);
 297         }
 298 
 299         parse->tp_cport->tmp_port_type = (uint_t)val;
 300 
 301         parse->tp_state = TOPO_USB_P_PORT;
 302         return (B_TRUE);
 303 }
 304 
 305 static boolean_t
 306 topo_usb_parse_path(topo_mod_t *mod, topo_usb_parse_t *parse,
 307     topo_usb_path_type_t ptype, const char *line)
 308 {
 309         char *fspath;
 310         topo_usb_meta_port_path_t *path;
 311 
 312         VERIFY(parse->tp_state == TOPO_USB_P_ACPI_PATH);
 313         VERIFY3P(parse->tp_cport, !=, NULL);