lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1648111505-5806-1-git-send-email-unSimple1993@163.com>
Date:   Thu, 24 Mar 2022 16:45:05 +0800
From:   QintaoShen <unSimple1993@....com>
To:     jckuo@...dia.com
Cc:     linux-kernel@...r.kernel.org, QintaoShen <unSimple1993@....com>
Subject: [PATCH v1] 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 <unSimple1993@....com>
---
 drivers/phy/tegra/xusb.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/phy/tegra/xusb.c b/drivers/phy/tegra/xusb.c
index aa5237e..f32b3cf 100644
--- a/drivers/phy/tegra/xusb.c
+++ b/drivers/phy/tegra/xusb.c
@@ -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,
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ