lkml.org 
[lkml]   [2017]   [Sep]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] cros_ec: sysfs: Fix memory leak in show/store_kb_wake_angle()
Date
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

\
 
 \ /
  Last update: 2017-09-29 11:14    [W:0.046 / U:4.120 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site