Re: [PATCH] cpufreq: ti-cpufreq: fix memory leak in ti_cpufreq_probe()

From: kernel test robot
Date: Mon Oct 19 2020 - 15:16:10 EST


Hi Defang,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on pm/linux-next]
[also build test ERROR on v5.9 next-20201016]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/0day-ci/linux/commits/Defang-Bo/cpufreq-ti-cpufreq-fix-memory-leak-in-ti_cpufreq_probe/20201019-214548
base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
config: arm-allyesconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/5a1fa3fa4d1aa57096d518b14240a0e5ea50c012
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Defang-Bo/cpufreq-ti-cpufreq-fix-memory-leak-in-ti_cpufreq_probe/20201019-214548
git checkout 5a1fa3fa4d1aa57096d518b14240a0e5ea50c012
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arm

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All error/warnings (new ones prefixed by >>):

drivers/cpufreq/ti-cpufreq.c: In function 'ti_cpufreq_probe':
>> drivers/cpufreq/ti-cpufreq.c:409:17: error: expected ';' before 'return'
409 | kfree(opp_data)
| ^
| ;
410 | return ret;
| ~~~~~~
>> drivers/cpufreq/ti-cpufreq.c:411:1: warning: control reaches end of non-void function [-Wreturn-type]
411 | }
| ^

vim +409 drivers/cpufreq/ti-cpufreq.c

322
323 static int ti_cpufreq_probe(struct platform_device *pdev)
324 {
325 u32 version[VERSION_COUNT];
326 const struct of_device_id *match;
327 struct opp_table *ti_opp_table;
328 struct ti_cpufreq_data *opp_data;
329 const char * const default_reg_names[] = {"vdd", "vbb"};
330 int ret;
331
332 match = dev_get_platdata(&pdev->dev);
333 if (!match)
334 return -ENODEV;
335
336 opp_data = devm_kzalloc(&pdev->dev, sizeof(*opp_data), GFP_KERNEL);
337 if (!opp_data)
338 return -ENOMEM;
339
340 opp_data->soc_data = match->data;
341
342 opp_data->cpu_dev = get_cpu_device(0);
343 if (!opp_data->cpu_dev) {
344 pr_err("%s: Failed to get device for CPU0\n", __func__);
345 ret = ENODEV;
346 goto free_opp_data;
347 }
348
349 opp_data->opp_node = dev_pm_opp_of_get_opp_desc_node(opp_data->cpu_dev);
350 if (!opp_data->opp_node) {
351 dev_info(opp_data->cpu_dev,
352 "OPP-v2 not supported, cpufreq-dt will attempt to use legacy tables.\n");
353 goto register_cpufreq_dt;
354 }
355
356 ret = ti_cpufreq_setup_syscon_register(opp_data);
357 if (ret)
358 goto fail_put_node;
359
360 /*
361 * OPPs determine whether or not they are supported based on
362 * two metrics:
363 * 0 - SoC Revision
364 * 1 - eFuse value
365 */
366 ret = ti_cpufreq_get_rev(opp_data, &version[0]);
367 if (ret)
368 goto fail_put_node;
369
370 ret = ti_cpufreq_get_efuse(opp_data, &version[1]);
371 if (ret)
372 goto fail_put_node;
373
374 ti_opp_table = dev_pm_opp_set_supported_hw(opp_data->cpu_dev,
375 version, VERSION_COUNT);
376 if (IS_ERR(ti_opp_table)) {
377 dev_err(opp_data->cpu_dev,
378 "Failed to set supported hardware\n");
379 ret = PTR_ERR(ti_opp_table);
380 goto fail_put_node;
381 }
382
383 opp_data->opp_table = ti_opp_table;
384
385 if (opp_data->soc_data->multi_regulator) {
386 const char * const *reg_names = default_reg_names;
387
388 if (opp_data->soc_data->reg_names)
389 reg_names = opp_data->soc_data->reg_names;
390 ti_opp_table = dev_pm_opp_set_regulators(opp_data->cpu_dev,
391 reg_names,
392 ARRAY_SIZE(default_reg_names));
393 if (IS_ERR(ti_opp_table)) {
394 dev_pm_opp_put_supported_hw(opp_data->opp_table);
395 ret = PTR_ERR(ti_opp_table);
396 goto fail_put_node;
397 }
398 }
399
400 of_node_put(opp_data->opp_node);
401 register_cpufreq_dt:
402 platform_device_register_simple("cpufreq-dt", -1, NULL, 0);
403
404 return 0;
405
406 fail_put_node:
407 of_node_put(opp_data->opp_node);
408 free_opp_data:
> 409 kfree(opp_data)
410 return ret;
> 411 }
412

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip