phy: tegra: xusb: Check for NULL return of devm_kzalloc()
PATCH 1/1 phy: tegra: xusb: Check for NULL return of devm_kzalloc()
The allocation of devm_kzalloc() may return a NULL pointer, can cause a NULL-pointer dereference in the follow lines of code.
To avoid this, it is better to check the return value of devm_kzalloc().
Signed-off-by QintaoShen <[email protected]>
--- drivers/phy/tegra/xusb.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/phy/tegra/xusb.c +3 -0
@@ -668,6 +668,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,
Signature · 1 line
2.7.4