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: <1508837659-22218-1-git-send-email-thierry.escande@collabora.com>
Date:   Tue, 24 Oct 2017 11:34:19 +0200
From:   Thierry Escande <thierry.escande@...labora.com>
To:     Benson Leung <bleung@...omium.org>, Olof Johansson <olof@...om.net>
Cc:     linux-kernel@...r.kernel.org
Subject: [PATCH] cros_ec: Fix a memory leak in show/store sysfs callbacks

This patch fixes a memory leak in the sysfs show/store callbacks of the
keyboard wake angle attribute. The EC message structure was allocated
but never freed.

Signed-off-by: Thierry Escande <thierry.escande@...labora.com>
---
 drivers/platform/chrome/cros_ec_sysfs.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/platform/chrome/cros_ec_sysfs.c b/drivers/platform/chrome/cros_ec_sysfs.c
index 0fd88eb..cc72bd0 100644
--- a/drivers/platform/chrome/cros_ec_sysfs.c
+++ b/drivers/platform/chrome/cros_ec_sysfs.c
@@ -286,10 +286,14 @@ 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,
@@ -319,6 +323,7 @@ static ssize_t store_kb_wake_angle(struct device *dev,
 	msg->outsize = sizeof(*param);
 	msg->insize = sizeof(struct ec_response_motion_sense);
 	ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg);
+	kfree(msg);
 	if (ret < 0)
 		return ret;
 	return count;
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ