All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [UBOOT PATCH] usb: ehci-hcd: Fix crash when rootdev not initialized
Date: Mon, 27 Jun 2016 13:05:20 +0200	[thread overview]
Message-ID: <d7133d44-3a98-2b63-ce86-f6a64b317995@redhat.com> (raw)
In-Reply-To: <1467017977-27631-1-git-send-email-sivadur@xilinx.com>

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@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;
>

  reply	other threads:[~2016-06-27 11:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-27  8:59 [U-Boot] [UBOOT PATCH] usb: ehci-hcd: Fix crash when rootdev not initialized Siva Durga Prasad Paladugu
2016-06-27 11:05 ` Hans de Goede [this message]
2016-06-28  6:06   ` Siva Durga Prasad Paladugu
2016-06-29  3:28     ` Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d7133d44-3a98-2b63-ce86-f6a64b317995@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.