Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Claudiu Beznea and committed by
Vinod Koul
44faada0 6cd52a2a

+3
+3
drivers/phy/tegra/xusb.c
··· 676 676 port->dev.driver = devm_kzalloc(&port->dev, 677 677 sizeof(struct device_driver), 678 678 GFP_KERNEL); 679 + if (!port->dev.driver) 680 + return -ENOMEM; 681 + 679 682 port->dev.driver->owner = THIS_MODULE; 680 683 681 684 port->usb_role_sw = usb_role_switch_register(&port->dev,