diff options
author | Stefan Mavrodiev <stefan@olimex.com> | 2018-12-05 14:49:44 +0200 |
---|---|---|
committer | Marek Vasut <marex@denx.de> | 2018-12-14 17:59:10 +0100 |
commit | 46a3f276549f3e5720b6e80278cda354c7fa859f (patch) | |
tree | b92d103424eb34926392333269f1c5629562ada7 /drivers/usb/musb-new/sunxi.c | |
parent | 771e76515ed5abe7eff73a54ccb0c9ae55f34388 (diff) |
usb: musb-new: sunxi: Fix null pointer access
When the device is in peripheral mode there is no
struct usb_bus_priv allocated pointer, as the uclass driver
("usb_dev_generic") doesn't call per_device_auto_alloc_size.
This results in writing to the internal SDRAM at
priv->desc_before_addr = true;
Signed-off-by: Stefan Mavrodiev <stefan@olimex.com>
Diffstat (limited to 'drivers/usb/musb-new/sunxi.c')
-rw-r--r-- | drivers/usb/musb-new/sunxi.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c index d7170a3078..f542a181fa 100644 --- a/drivers/usb/musb-new/sunxi.c +++ b/drivers/usb/musb-new/sunxi.c @@ -435,11 +435,14 @@ static int musb_usb_probe(struct udevice *dev) { struct sunxi_glue *glue = dev_get_priv(dev); struct musb_host_data *host = &glue->mdata; - struct usb_bus_priv *priv = dev_get_uclass_priv(dev); struct musb_hdrc_platform_data pdata; void *base = dev_read_addr_ptr(dev); int ret; +#ifdef CONFIG_USB_MUSB_HOST + struct usb_bus_priv *priv = dev_get_uclass_priv(dev); +#endif + if (!base) return -EINVAL; @@ -459,7 +462,6 @@ static int musb_usb_probe(struct udevice *dev) return ret; } - priv->desc_before_addr = true; memset(&pdata, 0, sizeof(pdata)); pdata.power = 250; @@ -467,6 +469,8 @@ static int musb_usb_probe(struct udevice *dev) pdata.config = glue->cfg->config; #ifdef CONFIG_USB_MUSB_HOST + priv->desc_before_addr = true; + pdata.mode = MUSB_HOST; host->host = musb_init_controller(&pdata, &glue->dev, base); if (!host->host) |