Message ID | 20230125065740.12504-1-quic_ugoswami@quicinc.com |
---|---|
State | New |
Headers | show |
Series | usb: gadget: configfs: Restrict symlink creation if UDC already binded | expand |
diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c index 78e7353e397b..434e49d29c50 100644 --- a/drivers/usb/gadget/configfs.c +++ b/drivers/usb/gadget/configfs.c @@ -455,6 +455,11 @@ static int config_usb_cfg_link( } } + if (gi->composite.gadget_driver.udc_name) { + ret = -EINVAL; + goto out; + } + f = usb_get_function(fi); if (IS_ERR(f)) { ret = PTR_ERR(f);
During enumeration or composition switch, if a userspace process agnostic of the conventions of configs tries to create function symlink seven after the UDC is bound to current config which is not correct. Potentially it can create duplicates within the current config. Prevent this by adding a check if udc_name already exists then bail out of cfg_link. Fixes: 88af8bbe4ef7 ("usb: gadget: the start of the configfs interface") Signed-off-by: Udipto Goswami <quic_ugoswami@quicinc.com> --- drivers/usb/gadget/configfs.c | 5 +++++ 1 file changed, 5 insertions(+)