usb: gadget: configfs: Disallow empty function instance name
Hi,
Quoted 21 lines · Krzysztof Opasiak
Every function should have a type and instance name. Unfortunately in most cases instance name was left unused and unchecked. This may lead to situations like FunctionFS device name identified by "" or some misleading debug messages from TCM like:
tcm: Activating
To avoid this let's add a check that instance name should have at least one character.
Reported-by Stefan Agner <[email protected]>Signed-off-by Krzysztof Opasiak <[email protected]>--- drivers/usb/gadget/configfs.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/usb/gadget/configfs.c +0
-0
drivers/usb/gadget/configfs.c static struct config_group *function_make( · line 554
Quoted 7 lines
drivers/usb/gadget/configfs.c +4
-0@@ -548,6 +548,11 @@ static struct config_group *function_make( *instance_name ='\0' ; instance_name++; +if (*instance_name =='\0' ) { +pr_err ("Instance name (after .) should not be empty\n" ); +return ERR_PTR (-EINVAL ); + }
aaaaaand just like that you break potentially existing scripts :-)
We need to find a better way of enforcing a name which doesn't break existing users.