Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1742005

[PATCH] cros_ec: sysfs: Fix memory leak in show/store_kb_wake_angle()

From Jeffy Chen <jeffy.chen@rock-chips.com>
Newsgroups linux.kernel
Subject [PATCH] cros_ec: sysfs: Fix memory leak in show/store_kb_wake_angle()
Date 2017-09-29 11:20 +0200
Message-ID <uuZCG-4gp-21@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


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@rock-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

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH] cros_ec: sysfs: Fix memory leak in show/store_kb_wake_angle() Jeffy Chen <jeffy.chen@rock-chips.com> - 2017-09-29 11:20 +0200

csiph-web