Skip to contentSkip to conversation

drivers/gpu/drm/nouveau/nvif/vmm.c:222 nvif_vmm_ctor() warn: possible memory leak of 'args'

DISCUSSION kernel test robot 1 participant 1 message Dec 3, 2023

lore
Share & tools
lore

kernel test robot

author build bot
#0 lore raw

BCC: [email protected]
CC: [email protected]
CC: [email protected]
TO: Danilo Krummrich <[email protected]>
CC: Dave Airlie <[email protected]>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   33cc938e65a98f1d29d0a18403dbbee050dcad9a
commit: 6b252cf42281045a9f803d2198023500cfa6ebd2 drm/nouveau: nvkm/vmm: implement raw ops to manage uvmm
date:   4 months ago

:::::: branch date: 13 hours ago
:::::: commit date: 4 months ago
config: i386-randconfig-141-20231105 (https://download.01.org/0day-ci/archive/20231204/[email protected]/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce: (https://download.01.org/0day-ci/archive/20231204/[email protected]/reproduce)

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]>
| Reported-by: Dan Carpenter <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

smatch warnings:
drivers/gpu/drm/nouveau/nvif/vmm.c:222 nvif_vmm_ctor() warn: possible memory leak of 'args'

vim +/args +222 drivers/gpu/drm/nouveau/nvif/vmm.c

920d2b5ef2157e Ben Skeggs       2017-11-01  197  
920d2b5ef2157e Ben Skeggs       2017-11-01  198  int
6b252cf4228104 Danilo Krummrich 2023-08-04  199  nvif_vmm_ctor(struct nvif_mmu *mmu, const char *name, s32 oclass,
6b252cf4228104 Danilo Krummrich 2023-08-04  200  	      enum nvif_vmm_type type, u64 addr, u64 size, void *argv, u32 argc,
6b252cf4228104 Danilo Krummrich 2023-08-04  201  	      struct nvif_vmm *vmm)
920d2b5ef2157e Ben Skeggs       2017-11-01  202  {
920d2b5ef2157e Ben Skeggs       2017-11-01  203  	struct nvif_vmm_v0 *args;
920d2b5ef2157e Ben Skeggs       2017-11-01  204  	u32 argn = sizeof(*args) + argc;
920d2b5ef2157e Ben Skeggs       2017-11-01  205  	int ret = -ENOSYS, i;
920d2b5ef2157e Ben Skeggs       2017-11-01  206  
920d2b5ef2157e Ben Skeggs       2017-11-01  207  	vmm->object.client = NULL;
920d2b5ef2157e Ben Skeggs       2017-11-01  208  	vmm->page = NULL;
920d2b5ef2157e Ben Skeggs       2017-11-01  209  
920d2b5ef2157e Ben Skeggs       2017-11-01  210  	if (!(args = kmalloc(argn, GFP_KERNEL)))
920d2b5ef2157e Ben Skeggs       2017-11-01  211  		return -ENOMEM;
920d2b5ef2157e Ben Skeggs       2017-11-01  212  	args->version = 0;
920d2b5ef2157e Ben Skeggs       2017-11-01  213  	args->addr = addr;
920d2b5ef2157e Ben Skeggs       2017-11-01  214  	args->size = size;
6b252cf4228104 Danilo Krummrich 2023-08-04  215  
6b252cf4228104 Danilo Krummrich 2023-08-04  216  	switch (type) {
6b252cf4228104 Danilo Krummrich 2023-08-04  217  	case UNMANAGED: args->type = NVIF_VMM_V0_TYPE_UNMANAGED; break;
6b252cf4228104 Danilo Krummrich 2023-08-04  218  	case MANAGED: args->type = NVIF_VMM_V0_TYPE_MANAGED; break;
6b252cf4228104 Danilo Krummrich 2023-08-04  219  	case RAW: args->type = NVIF_VMM_V0_TYPE_RAW; break;
6b252cf4228104 Danilo Krummrich 2023-08-04  220  	default:
6b252cf4228104 Danilo Krummrich 2023-08-04  221  		WARN_ON(1);

6b252cf4228104 Danilo Krummrich 2023-08-04 @222 return -EINVAL;

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