From: Yang Yingliang Date: Mon, 13 Feb 2023 07:09:26 +0000 (+0800) Subject: usb: gadget: uvc: fix missing mutex_unlock() if kstrtou8() fails X-Git-Tag: baikal/mips/sdk6.1~347 X-Git-Url: https://git.baikalelectronics.ru/sdk/?a=commitdiff_plain;h=f24b31fbe1188c0345f40a23dd78d18e1899656a;p=kernel.git usb: gadget: uvc: fix missing mutex_unlock() if kstrtou8() fails commit 95ae9b142c1e7966ff5c775630a4f4704b37cf26 upstream. If kstrtou8() fails, the mutex_unlock() is missed, move kstrtou8() before mutex_lock() to fix it up. Fixes: c79a82bd06fe ("usb: gadget: uvc: Allow definition of XUs in configfs") Fixes: dd4658813341 ("usb: gadget: uvc: Make bSourceID read/write") Signed-off-by: Yang Yingliang Link: https://lore.kernel.org/r/20230213070926.776447-1-yangyingliang@huawei.com Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/usb/gadget/function/uvc_configfs.c b/drivers/usb/gadget/function/uvc_configfs.c index 832565730d224..015a7bbd9bbfe 100644 --- a/drivers/usb/gadget/function/uvc_configfs.c +++ b/drivers/usb/gadget/function/uvc_configfs.c @@ -524,6 +524,10 @@ static ssize_t uvcg_default_output_b_source_id_store(struct config_item *item, int result; u8 num; + result = kstrtou8(page, 0, &num); + if (result) + return result; + mutex_lock(su_mutex); /* for navigating configfs hierarchy */ opts_item = group->cg_item.ci_parent->ci_parent-> @@ -531,10 +535,6 @@ static ssize_t uvcg_default_output_b_source_id_store(struct config_item *item, opts = to_f_uvc_opts(opts_item); cd = &opts->uvc_output_terminal; - result = kstrtou8(page, 0, &num); - if (result) - return result; - mutex_lock(&opts->lock); cd->bSourceID = num; mutex_unlock(&opts->lock);