Skip to content

Commit 9f42cf5

Browse files
Fabovireshk
authored andcommitted
cpufreq: qcom: fix memory leak in error path
If for some reason the speedbin length is incorrect, then there is a memory leak in the error path because we never free the speedbin buffer. This commit fixes the error path to always free the speedbin buffer. Cc: v5.7+ <[email protected]> # v5.7+ Fixes: a8811ec ("cpufreq: qcom: Add support for krait based socs") Signed-off-by: Fabien Parent <[email protected]> Signed-off-by: Viresh Kumar <[email protected]>
1 parent 1dcaf30 commit 9f42cf5

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/cpufreq/qcom-cpufreq-nvmem.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ static int qcom_cpufreq_krait_name_version(struct device *cpu_dev,
213213
int speed = 0, pvs = 0, pvs_ver = 0;
214214
u8 *speedbin;
215215
size_t len;
216+
int ret = 0;
216217

217218
speedbin = nvmem_cell_read(speedbin_nvmem, &len);
218219

@@ -230,16 +231,18 @@ static int qcom_cpufreq_krait_name_version(struct device *cpu_dev,
230231
break;
231232
default:
232233
dev_err(cpu_dev, "Unable to read nvmem data. Defaulting to 0!\n");
233-
return -ENODEV;
234+
ret = -ENODEV;
235+
goto len_error;
234236
}
235237

236238
snprintf(*pvs_name, sizeof("speedXX-pvsXX-vXX"), "speed%d-pvs%d-v%d",
237239
speed, pvs, pvs_ver);
238240

239241
drv->versions = (1 << speed);
240242

243+
len_error:
241244
kfree(speedbin);
242-
return 0;
245+
return ret;
243246
}
244247

245248
static const struct qcom_cpufreq_match_data match_data_kryo = {

0 commit comments

Comments
 (0)