[PATCH master 2/6] usb: gadget: don't register UMS with empty function

Ahmad Fatoum a.fatoum at pengutronix.de
Sat Mar 19 04:02:42 PDT 2022


system_partitions_get clones the system partitions and passes it along.
DFU and Fastboot use system partitions as a fallback and pass along a
NULL file list if they are empty. This enables e.g. usbgadget -A '' to
work: No files are expored, but fastboot OEM commands are possible.

USB mass storage though does pass along an empty system partitions file
list instead of NULL, which leads to bind failure, because UMS gadget
refuses to bind with no LUNs. Detect this case.

Fixes: 57313f83e83e ("usbgadget: add support for USB mass storage gadget")
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 common/usbgadget.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/usbgadget.c b/common/usbgadget.c
index 92e486199556..2ec6d9226cca 100644
--- a/common/usbgadget.c
+++ b/common/usbgadget.c
@@ -52,7 +52,7 @@ int usbgadget_register(const struct usbgadget_funcs *funcs)
 		opts->ums_opts.files = file_list_parse_null(funcs->ums_opts);
 		if (IS_ENABLED(CONFIG_USB_GADGET_MASS_STORAGE) && file_list_empty(opts->ums_opts.files)) {
 			file_list_free(opts->ums_opts.files);
-			opts->ums_opts.files = system_partitions_get();
+			opts->ums_opts.files = system_partitions_get_null();
 		}
 	}
 
-- 
2.30.2




More information about the barebox mailing list