diff options
author | Krzysztof Opasiak <k.opasiak@samsung.com> | 2017-12-12 14:30:38 +0100 |
---|---|---|
committer | Krzysztof Opasiak <k.opasiak@samsung.com> | 2017-12-12 14:52:50 +0100 |
commit | 1c3f1b4660ae2cc858f83806cf7d9d5543ff0298 (patch) | |
tree | 01ef637c1fc986ea29d66cfd481983b01ff826cb | |
parent | 904b04c4b46ec673197ad1d8291a0aabe6a34f52 (diff) | |
download | libusbg-1c3f1b4660ae2cc858f83806cf7d9d5543ff0298.tar.gz libusbg-1c3f1b4660ae2cc858f83806cf7d9d5543ff0298.tar.bz2 libusbg-1c3f1b4660ae2cc858f83806cf7d9d5543ff0298.zip |
libusbgx: fix: Disallow creating function with empty instance name
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.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
-rw-r--r-- | src/usbg.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -2048,7 +2048,7 @@ int usbg_create_function(usbg_gadget *g, usbg_function_type type, int ret = USBG_ERROR_INVALID_PARAM; int n, free_space; - if (!g || !f || !instance) + if (!g || !f || !instance || *instance == '\0') return ret; func = usbg_get_function(g, type, instance); |