mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re: [syzbot] memory leak in build_fu_desc
       [not found] <20261203191837.443069-1-vineet789thakran@gmail.com>
@ 2026-12-03 19:19 ` syzbot
  0 siblings, 0 replies; only message in thread
From: syzbot @ 2026-12-03 19:19 UTC (permalink / raw)
  To: vineet789thakran; +Cc: vineet789thakran, linux-kernel, syzkaller-bugs

> #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git e5aad2bdbbee783611d32599f89cea3f12f9593d

Patch testing via #syz test is temporarily disabled.
See https://github.com/google/syzkaller/issues/8122 for details.

>
> ---
> diff --git a/drivers/usb/gadget/function/f_uac1.c b/drivers/usb/gadget/function/f_uac1.c
> index 7539817cd407..2c892db84c65 100644
> --- a/drivers/usb/gadget/function/f_uac1.c
> +++ b/drivers/usb/gadget/function/f_uac1.c
> @@ -23,8 +23,8 @@
>  /* UAC1 spec: 3.7.2.3 Audio Channel Cluster Format */
>  #define UAC1_CHANNEL_MASK 0x0FFF
>  
> -#define USB_OUT_FU_ID	(out_feature_unit_desc->bUnitID)
> -#define USB_IN_FU_ID	(in_feature_unit_desc->bUnitID)
> +#define USB_OUT_FU_ID(_audio)	((_audio)->params.c_fu.id)
> +#define USB_IN_FU_ID(_audio)	((_audio)->params.p_fu.id)
>  
>  #define EPIN_EN(_opts) ((_opts)->p_chmask != 0)
>  #define EPOUT_EN(_opts) ((_opts)->c_chmask != 0)
> @@ -496,11 +496,11 @@ in_rq_cur(struct usb_function *fn, const struct usb_ctrlrequest *cr)
>  	u8 control_selector = w_value >> 8;
>  	int value = -EOPNOTSUPP;
>  
> -	if ((FUIN_EN(opts) && (entity_id == USB_IN_FU_ID)) ||
> -			(FUOUT_EN(opts) && (entity_id == USB_OUT_FU_ID))) {
> +	if ((FUIN_EN(opts) && (entity_id == USB_IN_FU_ID(audio))) ||
> +			(FUOUT_EN(opts) && (entity_id == USB_OUT_FU_ID(audio)))) {
>  		unsigned int is_playback = 0;
>  
> -		if (FUIN_EN(opts) && (entity_id == USB_IN_FU_ID))
> +		if (FUIN_EN(opts) && (entity_id == USB_IN_FU_ID(audio)))
>  			is_playback = 1;
>  
>  		if (control_selector == UAC_FU_MUTE) {
> @@ -547,11 +547,11 @@ in_rq_min(struct usb_function *fn, const struct usb_ctrlrequest *cr)
>  	u8 control_selector = w_value >> 8;
>  	int value = -EOPNOTSUPP;
>  
> -	if ((FUIN_EN(opts) && (entity_id == USB_IN_FU_ID)) ||
> -			(FUOUT_EN(opts) && (entity_id == USB_OUT_FU_ID))) {
> +	if ((FUIN_EN(opts) && (entity_id == USB_IN_FU_ID(audio))) ||
> +			(FUOUT_EN(opts) && (entity_id == USB_OUT_FU_ID(audio)))) {
>  		unsigned int is_playback = 0;
>  
> -		if (FUIN_EN(opts) && (entity_id == USB_IN_FU_ID))
> +		if (FUIN_EN(opts) && (entity_id == USB_IN_FU_ID(audio)))
>  			is_playback = 1;
>  
>  		if (control_selector == UAC_FU_VOLUME) {
> @@ -594,11 +594,11 @@ in_rq_max(struct usb_function *fn, const struct usb_ctrlrequest *cr)
>  	u8 control_selector = w_value >> 8;
>  	int value = -EOPNOTSUPP;
>  
> -	if ((FUIN_EN(opts) && (entity_id == USB_IN_FU_ID)) ||
> -			(FUOUT_EN(opts) && (entity_id == USB_OUT_FU_ID))) {
> +	if ((FUIN_EN(opts) && (entity_id == USB_IN_FU_ID(audio))) ||
> +			(FUOUT_EN(opts) && (entity_id == USB_OUT_FU_ID(audio)))) {
>  		unsigned int is_playback = 0;
>  
> -		if (FUIN_EN(opts) && (entity_id == USB_IN_FU_ID))
> +		if (FUIN_EN(opts) && (entity_id == USB_IN_FU_ID(audio)))
>  			is_playback = 1;
>  
>  		if (control_selector == UAC_FU_VOLUME) {
> @@ -641,11 +641,11 @@ in_rq_res(struct usb_function *fn, const struct usb_ctrlrequest *cr)
>  	u8 control_selector = w_value >> 8;
>  	int value = -EOPNOTSUPP;
>  
> -	if ((FUIN_EN(opts) && (entity_id == USB_IN_FU_ID)) ||
> -			(FUOUT_EN(opts) && (entity_id == USB_OUT_FU_ID))) {
> +	if ((FUIN_EN(opts) && (entity_id == USB_IN_FU_ID(audio))) ||
> +			(FUOUT_EN(opts) && (entity_id == USB_OUT_FU_ID(audio)))) {
>  		unsigned int is_playback = 0;
>  
> -		if (FUIN_EN(opts) && (entity_id == USB_IN_FU_ID))
> +		if (FUIN_EN(opts) && (entity_id == USB_IN_FU_ID(audio)))
>  			is_playback = 1;
>  
>  		if (control_selector == UAC_FU_VOLUME) {
> @@ -693,11 +693,11 @@ out_rq_cur_complete(struct usb_ep *ep, struct usb_request *req)
>  		return;
>  	}
>  
> -	if ((FUIN_EN(opts) && (entity_id == USB_IN_FU_ID)) ||
> -			(FUOUT_EN(opts) && (entity_id == USB_OUT_FU_ID))) {
> +	if ((FUIN_EN(opts) && (entity_id == USB_IN_FU_ID(audio))) ||
> +			(FUOUT_EN(opts) && (entity_id == USB_OUT_FU_ID(audio)))) {
>  		unsigned int is_playback = 0;
>  
> -		if (FUIN_EN(opts) && (entity_id == USB_IN_FU_ID))
> +		if (FUIN_EN(opts) && (entity_id == USB_IN_FU_ID(audio)))
>  			is_playback = 1;
>  
>  		if (control_selector == UAC_FU_MUTE) {
> @@ -742,8 +742,8 @@ out_rq_cur(struct usb_function *fn, const struct usb_ctrlrequest *cr)
>  	u8 entity_id = (w_index >> 8) & 0xff;
>  	u8 control_selector = w_value >> 8;
>  
> -	if ((FUIN_EN(opts) && (entity_id == USB_IN_FU_ID)) ||
> -			(FUOUT_EN(opts) && (entity_id == USB_OUT_FU_ID))) {
> +	if ((FUIN_EN(opts) && (entity_id == USB_IN_FU_ID(audio))) ||
> +			(FUOUT_EN(opts) && (entity_id == USB_OUT_FU_ID(audio)))) {
>  		memcpy(&uac1->setup_cr, cr, sizeof(*cr));
>  		req->context = audio;
>  		req->complete = out_rq_cur_complete;
> @@ -1277,14 +1277,14 @@ static int f_audio_bind(struct usb_configuration *c, struct usb_function *f)
>  		out_feature_unit_desc = build_fu_desc(audio_opts->c_chmask);
>  		if (!out_feature_unit_desc) {
>  			status = -ENOMEM;
> -			goto fail;
> +			goto free_ac_header;
>  		}
>  	}
>  	if (FUIN_EN(audio_opts)) {
>  		in_feature_unit_desc = build_fu_desc(audio_opts->p_chmask);
>  		if (!in_feature_unit_desc) {
>  			status = -ENOMEM;
> -			goto err_free_fu;
> +			goto free_fu;
>  		}
>  	}
>  
> @@ -1372,7 +1372,7 @@ static int f_audio_bind(struct usb_configuration *c, struct usb_function *f)
>  	/* allocate instance-specific interface IDs, and patch descriptors */
>  	status = usb_interface_id(c, f);
>  	if (status < 0)
> -		goto err_free_fu;
> +		goto free_fu;
>  	ac_interface_desc.bInterfaceNumber = status;
>  	uac1->ac_intf = status;
>  	uac1->ac_alt = 0;
> @@ -1382,7 +1382,7 @@ static int f_audio_bind(struct usb_configuration *c, struct usb_function *f)
>  	if (EPOUT_EN(audio_opts)) {
>  		status = usb_interface_id(c, f);
>  		if (status < 0)
> -			goto err_free_fu;
> +			goto free_fu;
>  		as_out_interface_alt_0_desc.bInterfaceNumber = status;
>  		as_out_interface_alt_1_desc.bInterfaceNumber = status;
>  		ac_header_desc->baInterfaceNr[ba_iface_id++] = status;
> @@ -1393,7 +1393,7 @@ static int f_audio_bind(struct usb_configuration *c, struct usb_function *f)
>  	if (EPIN_EN(audio_opts)) {
>  		status = usb_interface_id(c, f);
>  		if (status < 0)
> -			goto err_free_fu;
> +			goto free_fu;
>  		as_in_interface_alt_0_desc.bInterfaceNumber = status;
>  		as_in_interface_alt_1_desc.bInterfaceNumber = status;
>  		ac_header_desc->baInterfaceNr[ba_iface_id++] = status;
> @@ -1411,7 +1411,7 @@ static int f_audio_bind(struct usb_configuration *c, struct usb_function *f)
>  	if (FUOUT_EN(audio_opts) || FUIN_EN(audio_opts)) {
>  		ep = usb_ep_autoconfig(cdev->gadget, &ac_int_ep_desc);
>  		if (!ep)
> -			goto err_free_fu;
> +			goto free_fu;
>  		uac1->int_ep = ep;
>  		uac1->int_ep->desc = &ac_int_ep_desc;
>  
> @@ -1422,7 +1422,7 @@ static int f_audio_bind(struct usb_configuration *c, struct usb_function *f)
>  	if (EPOUT_EN(audio_opts)) {
>  		ep = usb_ep_autoconfig(cdev->gadget, &as_out_ep_desc);
>  		if (!ep)
> -			goto err_free_fu;
> +			goto free_fu;
>  		ss_as_out_ep_desc.bEndpointAddress = as_out_ep_desc.bEndpointAddress;
>  		audio->out_ep = ep;
>  		audio->out_ep->desc = &as_out_ep_desc;
> @@ -1431,7 +1431,7 @@ static int f_audio_bind(struct usb_configuration *c, struct usb_function *f)
>  	if (EPIN_EN(audio_opts)) {
>  		ep = usb_ep_autoconfig(cdev->gadget, &as_in_ep_desc);
>  		if (!ep)
> -			goto err_free_fu;
> +			goto free_fu;
>  		ss_as_in_ep_desc.bEndpointAddress = as_in_ep_desc.bEndpointAddress;
>  		audio->in_ep = ep;
>  		audio->in_ep->desc = &as_in_ep_desc;
> @@ -1443,7 +1443,7 @@ static int f_audio_bind(struct usb_configuration *c, struct usb_function *f)
>  	status = usb_assign_descriptors(f, f_audio_desc, f_audio_desc, f_audio_ss_desc,
>  					f_audio_ss_desc);
>  	if (status)
> -		goto err_free_fu;
> +		goto free_fu;
>  
>  	audio->out_ep_maxpsize = le16_to_cpu(as_out_ep_desc.wMaxPacketSize);
>  	audio->in_ep_maxpsize = le16_to_cpu(as_in_ep_desc.wMaxPacketSize);
> @@ -1452,7 +1452,7 @@ static int f_audio_bind(struct usb_configuration *c, struct usb_function *f)
>  			sizeof(audio->params.c_srates));
>  	audio->params.c_ssize = audio_opts->c_ssize;
>  	if (FUIN_EN(audio_opts)) {
> -		audio->params.p_fu.id = USB_IN_FU_ID;
> +		audio->params.p_fu.id = in_feature_unit_desc->bUnitID;
>  		audio->params.p_fu.mute_present = audio_opts->p_mute_present;
>  		audio->params.p_fu.volume_present =
>  				audio_opts->p_volume_present;
> @@ -1465,7 +1465,7 @@ static int f_audio_bind(struct usb_configuration *c, struct usb_function *f)
>  			sizeof(audio->params.p_srates));
>  	audio->params.p_ssize = audio_opts->p_ssize;
>  	if (FUOUT_EN(audio_opts)) {
> -		audio->params.c_fu.id = USB_OUT_FU_ID;
> +		audio->params.c_fu.id = out_feature_unit_desc->bUnitID;
>  		audio->params.c_fu.mute_present = audio_opts->c_mute_present;
>  		audio->params.c_fu.volume_present =
>  				audio_opts->c_volume_present;
> @@ -1480,18 +1480,19 @@ static int f_audio_bind(struct usb_configuration *c, struct usb_function *f)
>  
>  	status = g_audio_setup(audio, "UAC1_PCM", "UAC1_Gadget");
>  	if (status)
> -		goto err_card_register;
> +		usb_free_all_descriptors(f);
>  
> -	return 0;
> -
> -err_card_register:
> -	usb_free_all_descriptors(f);
> -err_free_fu:
> +free_fu:
> +	/*
> +	 * The feature unit and AC header descriptors are shared by all
> +	 * instances and only needed until usb_assign_descriptors() has
> +	 * copied them, so release them on every exit path.
> +	 */
>  	kfree(out_feature_unit_desc);
>  	out_feature_unit_desc = NULL;
>  	kfree(in_feature_unit_desc);
>  	in_feature_unit_desc = NULL;
> -fail:
> +free_ac_header:
>  	kfree(ac_header_desc);
>  	ac_header_desc = NULL;
>  	return status;
> @@ -1819,14 +1820,6 @@ static void f_audio_unbind(struct usb_configuration *c, struct usb_function *f)
>  	g_audio_cleanup(audio);
>  	usb_free_all_descriptors(f);
>  
> -	kfree(out_feature_unit_desc);
> -	out_feature_unit_desc = NULL;
> -	kfree(in_feature_unit_desc);
> -	in_feature_unit_desc = NULL;
> -
> -	kfree(ac_header_desc);
> -	ac_header_desc = NULL;
> -
>  	audio->gadget = NULL;
>  }
>  
> diff --git a/drivers/usb/gadget/function/f_uac2.c b/drivers/usb/gadget/function/f_uac2.c
> index a5f3d4d6c34b..6851832ca7d0 100644
> --- a/drivers/usb/gadget/function/f_uac2.c
> +++ b/drivers/usb/gadget/function/f_uac2.c
> @@ -31,8 +31,8 @@
>   */
>  #define USB_OUT_CLK_ID	(out_clk_src_desc.bClockID)
>  #define USB_IN_CLK_ID	(in_clk_src_desc.bClockID)
> -#define USB_OUT_FU_ID	(out_feature_unit_desc->bUnitID)
> -#define USB_IN_FU_ID	(in_feature_unit_desc->bUnitID)
> +#define USB_OUT_FU_ID(_agdev)	((_agdev)->params.c_fu.id)
> +#define USB_IN_FU_ID(_agdev)	((_agdev)->params.p_fu.id)
>  
>  #define CONTROL_ABSENT	0
>  #define CONTROL_RDONLY	1
> @@ -1095,7 +1095,7 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
>  		in_feature_unit_desc = build_fu_desc(p_channels);
>  		if (!in_feature_unit_desc) {
>  			ret = -ENOMEM;
> -			goto err_free_fu;
> +			goto free_fu;
>  		}
>  	}
>  
> @@ -1163,7 +1163,7 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
>  	ret = usb_interface_id(cfg, fn);
>  	if (ret < 0) {
>  		dev_err(dev, "%s:%d Error!\n", __func__, __LINE__);
> -		goto err_free_fu;
> +		goto free_fu;
>  	}
>  	iad_desc.bFirstInterface = ret;
>  
> @@ -1175,7 +1175,7 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
>  		ret = usb_interface_id(cfg, fn);
>  		if (ret < 0) {
>  			dev_err(dev, "%s:%d Error!\n", __func__, __LINE__);
> -			goto err_free_fu;
> +			goto free_fu;
>  		}
>  		std_as_out_if0_desc.bInterfaceNumber = ret;
>  		std_as_out_if1_desc.bInterfaceNumber = ret;
> @@ -1205,7 +1205,7 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
>  		ret = usb_interface_id(cfg, fn);
>  		if (ret < 0) {
>  			dev_err(dev, "%s:%d Error!\n", __func__, __LINE__);
> -			goto err_free_fu;
> +			goto free_fu;
>  		}
>  		std_as_in_if0_desc.bInterfaceNumber = ret;
>  		std_as_in_if1_desc.bInterfaceNumber = ret;
> @@ -1219,7 +1219,7 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
>  		if (!uac2->int_ep) {
>  			dev_err(dev, "%s:%d Error!\n", __func__, __LINE__);
>  			ret = -ENODEV;
> -			goto err_free_fu;
> +			goto free_fu;
>  		}
>  
>  		std_ac_if_desc.bNumEndpoints = 1;
> @@ -1235,42 +1235,42 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
>  					USB_SPEED_FULL, true);
>  	if (ret < 0) {
>  		dev_err(dev, "%s:%d Error!\n", __func__, __LINE__);
> -		return ret;
> +		goto free_fu;
>  	}
>  
>  	ret = set_ep_max_packet_size_bint(dev, uac2_opts, &fs_epout_desc,
>  					USB_SPEED_FULL, false);
>  	if (ret < 0) {
>  		dev_err(dev, "%s:%d Error!\n", __func__, __LINE__);
> -		return ret;
> +		goto free_fu;
>  	}
>  
>  	ret = set_ep_max_packet_size_bint(dev, uac2_opts, &hs_epin_desc,
>  					USB_SPEED_HIGH, true);
>  	if (ret < 0) {
>  		dev_err(dev, "%s:%d Error!\n", __func__, __LINE__);
> -		return ret;
> +		goto free_fu;
>  	}
>  
>  	ret = set_ep_max_packet_size_bint(dev, uac2_opts, &hs_epout_desc,
>  					USB_SPEED_HIGH, false);
>  	if (ret < 0) {
>  		dev_err(dev, "%s:%d Error!\n", __func__, __LINE__);
> -		return ret;
> +		goto free_fu;
>  	}
>  
>  	ret = set_ep_max_packet_size_bint(dev, uac2_opts, &ss_epin_desc,
>  					USB_SPEED_SUPER, true);
>  	if (ret < 0) {
>  		dev_err(dev, "%s:%d Error!\n", __func__, __LINE__);
> -		return ret;
> +		goto free_fu;
>  	}
>  
>  	ret = set_ep_max_packet_size_bint(dev, uac2_opts, &ss_epout_desc,
>  					USB_SPEED_SUPER, false);
>  	if (ret < 0) {
>  		dev_err(dev, "%s:%d Error!\n", __func__, __LINE__);
> -		return ret;
> +		goto free_fu;
>  	}
>  
>  	if (EPOUT_EN(uac2_opts)) {
> @@ -1278,7 +1278,7 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
>  		if (!agdev->out_ep) {
>  			dev_err(dev, "%s:%d Error!\n", __func__, __LINE__);
>  			ret = -ENODEV;
> -			goto err_free_fu;
> +			goto free_fu;
>  		}
>  		if (EPOUT_FBACK_IN_EN(uac2_opts)) {
>  			agdev->in_ep_fback = usb_ep_autoconfig(gadget,
> @@ -1287,7 +1287,7 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
>  				dev_err(dev, "%s:%d Error!\n",
>  					__func__, __LINE__);
>  				ret = -ENODEV;
> -				goto err_free_fu;
> +				goto free_fu;
>  			}
>  		}
>  	}
> @@ -1297,7 +1297,7 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
>  		if (!agdev->in_ep) {
>  			dev_err(dev, "%s:%d Error!\n", __func__, __LINE__);
>  			ret = -ENODEV;
> -			goto err_free_fu;
> +			goto free_fu;
>  		}
>  	}
>  
> @@ -1331,7 +1331,7 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
>  	ret = usb_assign_descriptors(fn, fs_audio_desc, hs_audio_desc, ss_audio_desc,
>  				     ss_audio_desc);
>  	if (ret)
> -		goto err_free_fu;
> +		goto free_fu;
>  
>  	agdev->gadget = gadget;
>  
> @@ -1340,7 +1340,7 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
>  			sizeof(agdev->params.p_srates));
>  	agdev->params.p_ssize = uac2_opts->p_ssize;
>  	if (FUIN_EN(uac2_opts)) {
> -		agdev->params.p_fu.id = USB_IN_FU_ID;
> +		agdev->params.p_fu.id = in_feature_unit_desc->bUnitID;
>  		agdev->params.p_fu.mute_present = uac2_opts->p_mute_present;
>  		agdev->params.p_fu.volume_present = uac2_opts->p_volume_present;
>  		agdev->params.p_fu.volume_min = uac2_opts->p_volume_min;
> @@ -1352,7 +1352,7 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
>  			sizeof(agdev->params.c_srates));
>  	agdev->params.c_ssize = uac2_opts->c_ssize;
>  	if (FUOUT_EN(uac2_opts)) {
> -		agdev->params.c_fu.id = USB_OUT_FU_ID;
> +		agdev->params.c_fu.id = out_feature_unit_desc->bUnitID;
>  		agdev->params.c_fu.mute_present = uac2_opts->c_mute_present;
>  		agdev->params.c_fu.volume_present = uac2_opts->c_volume_present;
>  		agdev->params.c_fu.volume_min = uac2_opts->c_volume_min;
> @@ -1366,15 +1366,17 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
>      agdev->notify = afunc_notify;
>  
>  	ret = g_audio_setup(agdev, "UAC2 PCM", "UAC2_Gadget");
> -	if (ret)
> -		goto err_free_descs;
> -
> -	return 0;
> +	if (ret) {
> +		usb_free_all_descriptors(fn);
> +		agdev->gadget = NULL;
> +	}
>  
> -err_free_descs:
> -	usb_free_all_descriptors(fn);
> -	agdev->gadget = NULL;
> -err_free_fu:
> +free_fu:
> +	/*
> +	 * The feature unit descriptors are shared by all instances and only
> +	 * needed until usb_assign_descriptors() has copied them, so release
> +	 * them on every exit path.
> +	 */
>  	kfree(out_feature_unit_desc);
>  	out_feature_unit_desc = NULL;
>  	kfree(in_feature_unit_desc);
> @@ -1586,11 +1588,11 @@ in_rq_cur(struct usb_function *fn, const struct usb_ctrlrequest *cr)
>  				"%s:%d control_selector=%d TODO!\n",
>  				__func__, __LINE__, control_selector);
>  		}
> -	} else if ((FUIN_EN(opts) && (entity_id == USB_IN_FU_ID)) ||
> -			(FUOUT_EN(opts) && (entity_id == USB_OUT_FU_ID))) {
> +	} else if ((FUIN_EN(opts) && (entity_id == USB_IN_FU_ID(agdev))) ||
> +			(FUOUT_EN(opts) && (entity_id == USB_OUT_FU_ID(agdev)))) {
>  		unsigned int is_playback = 0;
>  
> -		if (FUIN_EN(opts) && (entity_id == USB_IN_FU_ID))
> +		if (FUIN_EN(opts) && (entity_id == USB_IN_FU_ID(agdev)))
>  			is_playback = 1;
>  
>  		if (control_selector == UAC_FU_MUTE) {
> @@ -1675,11 +1677,11 @@ in_rq_range(struct usb_function *fn, const struct usb_ctrlrequest *cr)
>  				"%s:%d control_selector=%d TODO!\n",
>  				__func__, __LINE__, control_selector);
>  		}
> -	} else if ((FUIN_EN(opts) && (entity_id == USB_IN_FU_ID)) ||
> -			(FUOUT_EN(opts) && (entity_id == USB_OUT_FU_ID))) {
> +	} else if ((FUIN_EN(opts) && (entity_id == USB_IN_FU_ID(agdev))) ||
> +			(FUOUT_EN(opts) && (entity_id == USB_OUT_FU_ID(agdev)))) {
>  		unsigned int is_playback = 0;
>  
> -		if (FUIN_EN(opts) && (entity_id == USB_IN_FU_ID))
> +		if (FUIN_EN(opts) && (entity_id == USB_IN_FU_ID(agdev)))
>  			is_playback = 1;
>  
>  		if (control_selector == UAC_FU_VOLUME) {
> @@ -1765,11 +1767,11 @@ out_rq_cur_complete(struct usb_ep *ep, struct usb_request *req)
>  		return;
>  	}
>  
> -	if ((FUIN_EN(opts) && (entity_id == USB_IN_FU_ID)) ||
> -		(FUOUT_EN(opts) && (entity_id == USB_OUT_FU_ID))) {
> +	if ((FUIN_EN(opts) && (entity_id == USB_IN_FU_ID(agdev))) ||
> +		(FUOUT_EN(opts) && (entity_id == USB_OUT_FU_ID(agdev)))) {
>  		unsigned int is_playback = 0;
>  
> -		if (FUIN_EN(opts) && (entity_id == USB_IN_FU_ID))
> +		if (FUIN_EN(opts) && (entity_id == USB_IN_FU_ID(agdev)))
>  			is_playback = 1;
>  
>  		if (control_selector == UAC_FU_MUTE) {
> @@ -1819,8 +1821,8 @@ out_rq_cur(struct usb_function *fn, const struct usb_ctrlrequest *cr)
>  			req->complete = uac2_cs_control_sam_freq;
>  			return w_length;
>  		}
> -	} else if ((FUIN_EN(opts) && (entity_id == USB_IN_FU_ID)) ||
> -			(FUOUT_EN(opts) && (entity_id == USB_OUT_FU_ID))) {
> +	} else if ((FUIN_EN(opts) && (entity_id == USB_IN_FU_ID(agdev))) ||
> +			(FUOUT_EN(opts) && (entity_id == USB_OUT_FU_ID(agdev)))) {
>  		memcpy(&uac2->setup_cr, cr, sizeof(*cr));
>  		req->context = agdev;
>  		req->complete = out_rq_cur_complete;
> @@ -2305,11 +2307,6 @@ static void afunc_unbind(struct usb_configuration *c, struct usb_function *f)
>  	usb_free_all_descriptors(f);
>  
>  	agdev->gadget = NULL;
> -
> -	kfree(out_feature_unit_desc);
> -	out_feature_unit_desc = NULL;
> -	kfree(in_feature_unit_desc);
> -	in_feature_unit_desc = NULL;
>  }
>  
>  static struct usb_function *afunc_alloc(struct usb_function_instance *fi)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-12-03 19:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20261203191837.443069-1-vineet789thakran@gmail.com>
2026-12-03 19:19 ` [syzbot] memory leak in build_fu_desc syzbot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®