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>] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 22 Dec 2016 18:42:22 +0900
From:   Jaehoon Chung <jh80.chung@...sung.com>
To:     linux-kernel@...r.kernel.org
Cc:     kishon@...com, Jaehoon Chung <jh80.chung@...sung.com>
Subject: [PATCH] phy: core: check whether ops callback function is assigned

If some ops-> callback function are not assigend, then it should do the
unexpect behavior.
To prevent the potential NULL pointer dereference, check the each
callback functions before doing operation.

Signed-off-by: Jaehoon Chung <jh80.chung@...sung.com>
---
 drivers/phy/phy-core.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index a268f4d6f3e9..e4eb4431c8a4 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -219,7 +219,7 @@ int phy_init(struct phy *phy)
 {
 	int ret;
 
-	if (!phy)
+	if (!phy || !phy->ops->init)
 		return 0;
 
 	ret = phy_pm_runtime_get_sync(phy);
@@ -248,7 +248,7 @@ int phy_exit(struct phy *phy)
 {
 	int ret;
 
-	if (!phy)
+	if (!phy || !phy->ops->exit)
 		return 0;
 
 	ret = phy_pm_runtime_get_sync(phy);
@@ -277,7 +277,7 @@ int phy_power_on(struct phy *phy)
 {
 	int ret = 0;
 
-	if (!phy)
+	if (!phy || !phy->ops->power_on)
 		goto out;
 
 	if (phy->pwr) {
@@ -319,7 +319,7 @@ int phy_power_off(struct phy *phy)
 {
 	int ret;
 
-	if (!phy)
+	if (!phy || !phy->ops->power_off)
 		return 0;
 
 	mutex_lock(&phy->mutex);
-- 
2.11.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ