lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <91225fb4-1184-cb4c-1716-f067a407a37f@synopsys.com>
Date: Wed, 5 Feb 2025 07:29:35 +0000
From: Minas Harutyunyan <Minas.Harutyunyan@...opsys.com>
To: Fabrice Gasnier <fabrice.gasnier@...s.st.com>,
        Minas Harutyunyan <Minas.Harutyunyan@...opsys.com>,
        "gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>
CC: "linux-usb@...r.kernel.org" <linux-usb@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "linux-stm32@...md-mailman.stormreply.com"
	<linux-stm32@...md-mailman.stormreply.com>
Subject: Re: [PATCH] usb: dwc2: gadget: remove of_node reference upon udc_stop



On 1/24/25 21:33, Fabrice Gasnier wrote:
> In dwc2_hsotg_udc_start(), e.g. when binding composite driver, "of_node"
> is set to hsotg->dev->of_node.
> 
> It causes errors when binding the gadget driver several times, on
> stm32mp157c-ev1 board. Below error is seen:
> "pin PA10 already requested by 49000000.usb-otg; cannot claim for gadget.0"
> 
> The first time, no issue is seen as when registering the driver, of_node
> isn't NULL:
> -> gadget_dev_desc_UDC_store
>    -> usb_gadget_register_driver_owner
>      -> driver_register
>      ...
>        -> really_probe -> pinctrl_bind_pins (no effect)
> 
> Then dwc2_hsotg_udc_start() sets of_node.
> 
> The second time (stop the gadget, reconfigure it, then start it again),
> of_node has been set, so the probing code tries to acquire pins for the
> gadget. These pins are hold by the controller, hence the error.
> 
> So clear gadget.dev.of_node in udc_stop() routine to avoid the issue.
> 
> Fixes: 7d7b22928b90 ("usb: gadget: s3c-hsotg: Propagate devicetree to gadget drivers")
> Signed-off-by: Fabrice Gasnier <fabrice.gasnier@...s.st.com>

Acked-by: Minas Harutyunyan <hminas@...opsys.com>

> ---
> Note: I'd have been tempted to remove of_node setting from udc_start:
>   -	hsotg->gadget.dev.of_node = hsotg->dev->of_node;
> 
> I can't find the original code that parses the device node [1] from
> composite_bind() routine, originally part of the series that introduces
> this.
> I'm not sure if setting the gadget of_node is really useful, but I chose
> safe approach to simply clear it in udc_stop().
> 
> [1] https://urldefense.com/v3/__http://lore.kernel.org/lkml/1340720833-781-6-git-send-email-aletes.xgr@gmail.com/__;!!A4F2R9G_pg!b_OA_O4ZVXni3sf4SlcXVsbj4XALvNCfFsUJiGi1BlLOq99J4lZ70VmUBhdZdsU3NwSCSEG_BNfHHP8mfYG1vTBBEYw$
> ---
>   drivers/usb/dwc2/gadget.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
> index e7bf9cc635be..bd4c788f03bc 100644
> --- a/drivers/usb/dwc2/gadget.c
> +++ b/drivers/usb/dwc2/gadget.c
> @@ -4615,6 +4615,7 @@ static int dwc2_hsotg_udc_stop(struct usb_gadget *gadget)
>   	spin_lock_irqsave(&hsotg->lock, flags);
>   
>   	hsotg->driver = NULL;
> +	hsotg->gadget.dev.of_node = NULL;
>   	hsotg->gadget.speed = USB_SPEED_UNKNOWN;
>   	hsotg->enabled = 0;
>   

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ