Skip to content

Commit 44faada

Browse files
claudiubezneavinodkoul
authored andcommitted
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: f67213c ("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>
1 parent 6cd52a2 commit 44faada

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

drivers/phy/tegra/xusb.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,9 @@ static int tegra_xusb_setup_usb_role_switch(struct tegra_xusb_port *port)
676676
port->dev.driver = devm_kzalloc(&port->dev,
677677
sizeof(struct device_driver),
678678
GFP_KERNEL);
679+
if (!port->dev.driver)
680+
return -ENOMEM;
681+
679682
port->dev.driver->owner = THIS_MODULE;
680683

681684
port->usb_role_sw = usb_role_switch_register(&port->dev,

0 commit comments

Comments
 (0)