diff options
author | Claudiu Beznea <claudiu.beznea@microchip.com> | 2023-05-31 09:39:50 +0200 |
---|---|---|
committer | Vinod Koul <vkoul@kernel.org> | 2023-06-21 19:58:52 +0200 |
commit | 44faada0f38fc333d392af04c343b0e23f8f5d81 (patch) | |
tree | 3d4084c2092cb7420e689f8b22ed9ec008160798 /drivers/phy | |
parent | phy: qcom: qmp-combo: fix Display Port PHY configuration for SM8550 (diff) | |
download | linux-44faada0f38fc333d392af04c343b0e23f8f5d81.tar.xz linux-44faada0f38fc333d392af04c343b0e23f8f5d81.zip |
phy: tegra: xusb: check return value of devm_kzalloc()
devm_kzalloc() returns a pointer to dynamically allocated memory.
Pointer could be NULL in case allocation fails. Check pointer validity.
Identified with coccinelle (kmerr.cocci script).
Fixes: f67213cee2b3 ("phy: tegra: xusb: Add usb-role-switch support")
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Acked-by: Thierry Reding <treding@nvidia.com>
Link: https://lore.kernel.org/r/20230531073950.145339-1-claudiu.beznea@microchip.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Diffstat (limited to 'drivers/phy')
-rw-r--r-- | drivers/phy/tegra/xusb.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/phy/tegra/xusb.c b/drivers/phy/tegra/xusb.c index b5bad46a04a3..a296b87dced1 100644 --- a/drivers/phy/tegra/xusb.c +++ b/drivers/phy/tegra/xusb.c @@ -676,6 +676,9 @@ static int tegra_xusb_setup_usb_role_switch(struct tegra_xusb_port *port) port->dev.driver = devm_kzalloc(&port->dev, sizeof(struct device_driver), GFP_KERNEL); + if (!port->dev.driver) + return -ENOMEM; + port->dev.driver->owner = THIS_MODULE; port->usb_role_sw = usb_role_switch_register(&port->dev, |