Deleted Added
sdiff udiff text old ( 198376 ) new ( 199055 )
full compact
1/* $FreeBSD: head/lib/libusb/libusb20_ugen20.c 198376 2009-10-22 21:01:41Z thompsa $ */
2/*-
3 * Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.

--- 434 unchanged lines hidden (view full) ---

444 uint8_t **ppbuf, uint16_t *plen, uint8_t cfg_index)
445{
446 struct usb_gen_descriptor gen_desc;
447 struct usb_config_descriptor cdesc;
448 uint8_t *ptr;
449 uint16_t len;
450 int error;
451
452 memset(&gen_desc, 0, sizeof(gen_desc));
453
454 gen_desc.ugd_data = &cdesc;
455 gen_desc.ugd_maxlen = sizeof(cdesc);
456 gen_desc.ugd_config_index = cfg_index;
457
458 error = ioctl(pdev->file_ctrl, USB_GET_FULL_DESC, &gen_desc);
459 if (error) {
460 return (LIBUSB20_ERROR_OTHER);
461 }
462 len = UGETW(cdesc.wTotalLength);
463 if (len < sizeof(cdesc)) {
464 /* corrupt descriptor */
465 return (LIBUSB20_ERROR_OTHER);
466 }
467 ptr = malloc(len);
468 if (!ptr) {
469 return (LIBUSB20_ERROR_NO_MEM);
470 }
471 gen_desc.ugd_data = ptr;
472 gen_desc.ugd_maxlen = len;
473
474 error = ioctl(pdev->file_ctrl, USB_GET_FULL_DESC, &gen_desc);
475 if (error) {
476 free(ptr);
477 return (LIBUSB20_ERROR_OTHER);
478 }

--- 511 unchanged lines hidden ---