[U-Boot] [UBOOT PATCH] usb: ehci-hcd: Fix crash when rootdev not initialized

Hans de Goede hdegoede at redhat.com
Mon Jun 27 13:05:20 CEST 2016


Hi,

On 27-06-16 10:59, Siva Durga Prasad Paladugu wrote:
> This patch fixes the issue on zynq USB failure with DM
> when rootdev is not initialized. This variable is initalized
> to zero in non driver model case but not in DM.
>
> Signed-off-by: Siva Durga Prasad Paladugu <sivadur at xilinx.com>
> ---
> - Tested on Zynq ZC702 board with USB DM driver model patches
>   sent by Simon.

This patch does not seem like the right fix, normally something
like the ehci_ctrl struct would be allocated by dm by setting
priv_auto_alloc_size in the driver description, and then the
data will get calloc-ed. If you're allocating the ehci_ctrl struct
differently and not memsetting it to 0 you may have other bugs
lurking, or may get new bugs when new members get added in the
future.

My advice would be to use priv_auto_alloc_size, see .e.g :
drivers/usb/host/ehci-sunxi.c

If you cannot use that for some reason, make sure to memset
struct ehci_Ctrl to 0 before calling ehci_register()

Regards,

Hans



> ---
>  drivers/usb/host/ehci-hcd.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
> index 13aa70d..8adffa6 100644
> --- a/drivers/usb/host/ehci-hcd.c
> +++ b/drivers/usb/host/ehci-hcd.c
> @@ -1624,6 +1624,8 @@ int ehci_register(struct udevice *dev, struct ehci_hccr *hccr,
>  			goto err;
>  	}
>
> +	ctrl->rootdev = 0;
> +
>  	ret = ehci_common_init(ctrl, tweaks);
>  	if (ret)
>  		goto err;
>


More information about the U-Boot mailing list