Skip to contentSkip to conversation

drivers/firmware/imx/se_ctrl.c:476:2-7: WARNING: invalid free of devm_ allocated data

PATCH kernel test robot 1 participant 1 message May 8

lore
Share & tools
lore

kernel test robot

author build bot
#0 lore raw
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/frank.li/linux.git imx/firmware-ele
head:   63536a73a3bbf69d097e45c4f3d419ee32533f20
commit: 63536a73a3bbf69d097e45c4f3d419ee32533f20 [5/5] firmware: drivers: imx: adds miscdev
config: arm-randconfig-r054-20260509 (https://download.01.org/0day-ci/archive/20260509/[email protected]/config)
compiler: arm-linux-gnueabi-gcc (GCC) 15.2.0

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

cocci warnings: (new ones prefixed by >>)

>> drivers/firmware/imx/se_ctrl.c:476:2-7: WARNING: invalid free of devm_ allocated data
   drivers/firmware/imx/se_ctrl.c:487:2-7: WARNING: invalid free of devm_ allocated data
--
>> drivers/firmware/imx/se_ctrl.c:491:16-23: ERROR: reference preceded by free on line 487

vim +476 drivers/firmware/imx/se_ctrl.c

460
461 static int init_device_context(struct se_if_priv *priv, int ch_id,
462 struct se_if_device_ctx **new_dev_ctx)
463 {
464 struct se_if_device_ctx *dev_ctx;
465 int ret = 0;
466
467 dev_ctx = kzalloc_obj(*dev_ctx, GFP_KERNEL);
468
469 if (!dev_ctx)
470 return -ENOMEM;
471
472 dev_ctx->devname = kasprintf(GFP_KERNEL, "%s0_ch%d",
473 get_se_if_name(priv->if_defs->se_if_type),
474 ch_id);
475 if (!dev_ctx->devname) {

 > 476			kfree(dev_ctx);
   477			return -ENOMEM;
   478		}
   479	
   480		mutex_init(&dev_ctx->fops_lock);
   481		dev_ctx->priv = priv;
   482		*new_dev_ctx = dev_ctx;
   483	
   484		ret = init_se_shared_mem(dev_ctx);
   485		if (ret < 0) {
   486			kfree(dev_ctx->devname);
 > 487			kfree(dev_ctx);
   488			*new_dev_ctx = NULL;
   489		}
   490	
 > 491		list_add_tail(&dev_ctx->link, &priv->dev_ctx_list);

492 priv->active_devctx_count++;
493
494 return ret;
495 }
496

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki