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: <20170929091309.28860-1-jeffy.chen@rock-chips.com>
Date:   Fri, 29 Sep 2017 17:13:08 +0800
From:   Jeffy Chen <jeffy.chen@...k-chips.com>
To:     linux-kernel@...r.kernel.org
Cc:     Jeffy Chen <jeffy.chen@...k-chips.com>,
        Olof Johansson <olof@...om.net>,
        Benson Leung <bleung@...omium.org>
Subject: [PATCH] cros_ec: sysfs: Fix memory leak in show/store_kb_wake_angle()

Add missing kfree of allocated cros_ec_command.

Fixes: ff00af859354 ("platform/chrome: cros_ec: Add sysfs entry to set keyboard wake lid angle")
Signed-off-by: Jeffy Chen <jeffy.chen@...k-chips.com>
---

 drivers/platform/chrome/cros_ec_sysfs.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/platform/chrome/cros_ec_sysfs.c b/drivers/platform/chrome/cros_ec_sysfs.c
index 0fd88eb03d39..0f821dd0d5b1 100644
--- a/drivers/platform/chrome/cros_ec_sysfs.c
+++ b/drivers/platform/chrome/cros_ec_sysfs.c
@@ -286,10 +286,12 @@ static ssize_t show_kb_wake_angle(struct device *dev,
 	msg->insize = sizeof(*resp);
 	ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg);
 	if (ret < 0)
-		return ret;
+		goto exit;
 	resp = (struct ec_response_motion_sense *)msg->data;
-	return scnprintf(buf, PAGE_SIZE, "%d\n",
-			 resp->kb_wake_angle.ret);
+	ret = scnprintf(buf, PAGE_SIZE, "%d\n", resp->kb_wake_angle.ret);
+exit:
+	kfree(msg);
+	return ret;
 }
 
 static ssize_t store_kb_wake_angle(struct device *dev,
@@ -320,8 +322,11 @@ static ssize_t store_kb_wake_angle(struct device *dev,
 	msg->insize = sizeof(struct ec_response_motion_sense);
 	ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg);
 	if (ret < 0)
-		return ret;
-	return count;
+		goto exit;
+	ret = count;
+exit:
+	kfree(msg);
+	return ret;
 }
 
 /* Module initialization */
-- 
2.11.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ