Skip to content
  • Jon Hunter's avatar
    usb: tegra: Fix allocation for the FPCI context · 0b987032
    Jon Hunter authored
    Commit 5c4e8d37 ("usb: host: xhci-tegra: Add support for XUSB
    context save/restore") is using the IPFS 'num_offsets' value when
    allocating memory for FPCI context instead of the FPCI 'num_offsets'.
    
    After commit cad064f1 ("devres: handle zero size in devm_kmalloc()")
    was added system suspend started failing on Tegra186. The kernel log
    showed that the Tegra XHCI driver was crashing on entry to suspend when
    attempting the save the USB context. On Tegra186, the IPFS context has a
    zero length but the FPCI content has a non-zero length, and because of
    the bug in the Tegra XHCI driver we are incorrectly allocating a zero
    length array for the FPCI context. The crash seen on entering suspend
    when we attempt to save the FPCI context and following commit
    cad064f1 ("devres: handle zero size in devm_kmalloc()") this now
    causes a NULL pointer deference when we access the memory. Fix this by
    correcting the amount of memory we are allocating for FPCI contexts.
    
    Cc: stable@vger.kernel.org
    
    Fixes: 5c4e8d37
    
     ("usb: host: xhci-tegra: Add support for XUSB context save/restore")
    
    Signed-off-by: default avatarJon Hunter <jonathanh@nvidia.com>
    Acked-by: default avatarThierry Reding <treding@nvidia.com>
    Link: https://lore.kernel.org/r/20200715113842.30680-1-jonathanh@nvidia.com
    
    
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    0b987032