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

Commit 8d5e095b authored by Sharat Masetty's avatar Sharat Masetty
Browse files

msm: kgsl: fix mem leak in adreno_read_speed_bin()



The nvmem_cell_read() allocates a buffer which needs to be
freed by the consumer after use. This patch fixes this memory
leak.

Change-Id: I4ee81880f449288be1c82498bf460cdc17ab10a8
Signed-off-by: default avatarSharat Masetty <smasetty@codeaurora.org>
parent 0780e20a
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -1289,6 +1289,8 @@ static int adreno_read_speed_bin(struct platform_device *pdev,
{
	struct nvmem_cell *cell = nvmem_cell_get(&pdev->dev, "speed_bin");
	int ret = PTR_ERR_OR_ZERO(cell);
	void *buf;
	size_t len;

	if (ret) {
		/*
@@ -1301,7 +1303,12 @@ static int adreno_read_speed_bin(struct platform_device *pdev,
		return ret;
	}

	adreno_dev->speed_bin = *((unsigned int *) nvmem_cell_read(cell, NULL));
	buf = nvmem_cell_read(cell, &len);
	if (!IS_ERR(buf)) {
		memcpy(&adreno_dev->speed_bin, buf,
				min(len, sizeof(adreno_dev->speed_bin)));
		kfree(buf);
	}

	nvmem_cell_put(cell);