linux-usb-gadgets / libusbgx

C library encapsulating the Linux kernel USB gadget configfs userspace API functionality
GNU General Public License v2.0
216 stars 72 forks source link

Disallow creating function with empty instance name #20

Closed kopasiak closed 6 years ago

kopasiak commented 6 years ago

USB function should have both type and instance name. Mistakenly it was possible to create function with empty instance name. This may lead to situations like FunctionFS device name identified by "" or some misleading debug messages from TCM like:

tcm: Activating

Additionaly trying to execute usbg_init() after creating such a function fails with -3 USBG_ERROR_INVALID_PARAM because it checks if instance name is not empty.

To avoid this let's add a check in usbg_create_function() that instance name should have at least one character.

This fixes #19

If anyone here has any objections to this please let me now as soon as possible.