* [PATCH] cros_ec: sysfs: Fix memory leak in show/store_kb_wake_angle()
@ 2017-09-29 9:13 Jeffy Chen
0 siblings, 0 replies; only message in thread
From: Jeffy Chen @ 2017-09-29 9:13 UTC (permalink / raw)
To: linux-kernel; +Cc: Jeffy Chen, Olof Johansson, Benson Leung
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-09-29 9:13 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-29 9:13 [PATCH] cros_ec: sysfs: Fix memory leak in show/store_kb_wake_angle() Jeffy Chen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®