Skip to content

Commit 0b98703

Browse files
jonhuntergregkh
authored andcommitted
usb: tegra: Fix allocation for the FPCI context
Commit 5c4e8d3 ("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 cad064f ("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 cad064f ("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: [email protected] Fixes: 5c4e8d3 ("usb: host: xhci-tegra: Add support for XUSB context save/restore") Signed-off-by: Jon Hunter <[email protected]> Acked-by: Thierry Reding <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent dbb0897 commit 0b98703

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/usb/host/xhci-tegra.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@ static int tegra_xusb_init_context(struct tegra_xusb *tegra)
856856
if (!tegra->context.ipfs)
857857
return -ENOMEM;
858858

859-
tegra->context.fpci = devm_kcalloc(tegra->dev, soc->ipfs.num_offsets,
859+
tegra->context.fpci = devm_kcalloc(tegra->dev, soc->fpci.num_offsets,
860860
sizeof(u32), GFP_KERNEL);
861861
if (!tegra->context.fpci)
862862
return -ENOMEM;

0 commit comments

Comments
 (0)