Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 86136f9a authored by Jaiju Yesudasan's avatar Jaiju Yesudasan
Browse files

profiler: Fix Possible memory leak



Avoid possible memory leak by the dynamic memory stored in 'bwbuf'
allocated through function 'kzalloc' when met with error condition
and function return.

Change-Id: I87607bf64e75ada7a8062bb28585eda26cdfbfbd
Signed-off-by: default avatarJaiju Yesudasan <cjaijuy@codeaurora.org>
parent f5be93c4
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -226,16 +226,16 @@ static int profiler_get_bw_info(void __user *argp)
	struct tz_bw_svc_buf *bwbuf = NULL;
	struct profiler_bw_cntrs_req cnt_buf;

	/* Allocate memory for request */
	bwbuf = kzalloc(PAGE_ALIGN(sizeof(struct tz_bw_svc_buf)), GFP_KERNEL);
	if (bwbuf == NULL)
		return -ENOMEM;
	ret = copy_from_user(&cnt_buf, argp,
				sizeof(struct profiler_bw_cntrs_req));
	if (ret) {
		pr_err("copy_from_user failed\n");
		return ret;
	}
	/* Allocate memory for request */
	bwbuf = kzalloc(PAGE_ALIGN(sizeof(struct tz_bw_svc_buf)), GFP_KERNEL);
	if (bwbuf == NULL)
		return -ENOMEM;
	switch (cnt_buf.cmd) {
	case TZ_BW_SVC_START_ID: {
		ret = bw_profiling_start(bwbuf);
@@ -257,7 +257,7 @@ static int profiler_get_bw_info(void __user *argp)
	}
	default:
		pr_err("Invalid IOCTL: 0x%x\n", cnt_buf.cmd);
		return -EINVAL;
		ret = -EINVAL;
	}
	/* Free memory for command */
	if (bwbuf != NULL) {