All of lore.kernel.org
 help / color / mirror / Atom feed
* [linux-next:master 8309/10976] drivers/gpu/host1x/context.c:82 host1x_memory_context_list_init() warn: missing error code 'err'
@ 2023-04-13  5:06 Dan Carpenter
  2023-04-13  8:57 ` Thierry Reding
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2023-04-13  5:06 UTC (permalink / raw)
  To: oe-kbuild, Christian König
  Cc: lkp, oe-kbuild-all, Linux Memory Management List, Thierry Reding

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   7d8214bba44c1aa6a75921a09a691945d26a8d43
commit: f75d19827b731c6f24930ef77e5a46cf2242bc68 [8309/10976] drm/tegra: Allow compile test on !ARM v2
config: xtensa-randconfig-m041-20230411 (https://download.01.org/0day-ci/archive/20230413/202304131214.MOOEMszN-lkp@intel.com/config)
compiler: xtensa-linux-gcc (GCC) 12.1.0

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Link: https://lore.kernel.org/r/202304131214.MOOEMszN-lkp@intel.com/

smatch warnings:
drivers/gpu/host1x/context.c:82 host1x_memory_context_list_init() warn: missing error code 'err'

vim +/err +82 drivers/gpu/host1x/context.c

8aa5bcb6161206 Mikko Perttunen 2022-06-27  21  int host1x_memory_context_list_init(struct host1x *host1x)
8aa5bcb6161206 Mikko Perttunen 2022-06-27  22  {
8aa5bcb6161206 Mikko Perttunen 2022-06-27  23  	struct host1x_memory_context_list *cdl = &host1x->context_list;
8aa5bcb6161206 Mikko Perttunen 2022-06-27  24  	struct device_node *node = host1x->dev->of_node;
8aa5bcb6161206 Mikko Perttunen 2022-06-27  25  	struct host1x_memory_context *ctx;
8aa5bcb6161206 Mikko Perttunen 2022-06-27  26  	unsigned int i;
8aa5bcb6161206 Mikko Perttunen 2022-06-27  27  	int err;
8aa5bcb6161206 Mikko Perttunen 2022-06-27  28  
8aa5bcb6161206 Mikko Perttunen 2022-06-27  29  	cdl->devs = NULL;
8aa5bcb6161206 Mikko Perttunen 2022-06-27  30  	cdl->len = 0;
8aa5bcb6161206 Mikko Perttunen 2022-06-27  31  	mutex_init(&cdl->lock);
8aa5bcb6161206 Mikko Perttunen 2022-06-27  32  
8aa5bcb6161206 Mikko Perttunen 2022-06-27  33  	err = of_property_count_u32_elems(node, "iommu-map");
8aa5bcb6161206 Mikko Perttunen 2022-06-27  34  	if (err < 0)
8aa5bcb6161206 Mikko Perttunen 2022-06-27  35  		return 0;
8aa5bcb6161206 Mikko Perttunen 2022-06-27  36  
8aa5bcb6161206 Mikko Perttunen 2022-06-27  37  	cdl->devs = kcalloc(err, sizeof(*cdl->devs), GFP_KERNEL);
8aa5bcb6161206 Mikko Perttunen 2022-06-27  38  	if (!cdl->devs)
8aa5bcb6161206 Mikko Perttunen 2022-06-27  39  		return -ENOMEM;
8aa5bcb6161206 Mikko Perttunen 2022-06-27  40  	cdl->len = err / 4;
8aa5bcb6161206 Mikko Perttunen 2022-06-27  41  
8aa5bcb6161206 Mikko Perttunen 2022-06-27  42  	for (i = 0; i < cdl->len; i++) {
8aa5bcb6161206 Mikko Perttunen 2022-06-27  43  		ctx = &cdl->devs[i];
8aa5bcb6161206 Mikko Perttunen 2022-06-27  44  
8aa5bcb6161206 Mikko Perttunen 2022-06-27  45  		ctx->host = host1x;
8aa5bcb6161206 Mikko Perttunen 2022-06-27  46  
8aa5bcb6161206 Mikko Perttunen 2022-06-27  47  		device_initialize(&ctx->dev);
8aa5bcb6161206 Mikko Perttunen 2022-06-27  48  
8aa5bcb6161206 Mikko Perttunen 2022-06-27  49  		/*
8aa5bcb6161206 Mikko Perttunen 2022-06-27  50  		 * Due to an issue with T194 NVENC, only 38 bits can be used.
8aa5bcb6161206 Mikko Perttunen 2022-06-27  51  		 * Anyway, 256GiB of IOVA ought to be enough for anyone.
8aa5bcb6161206 Mikko Perttunen 2022-06-27  52  		 */
8aa5bcb6161206 Mikko Perttunen 2022-06-27  53  		ctx->dma_mask = DMA_BIT_MASK(38);
8aa5bcb6161206 Mikko Perttunen 2022-06-27  54  		ctx->dev.dma_mask = &ctx->dma_mask;
8aa5bcb6161206 Mikko Perttunen 2022-06-27  55  		ctx->dev.coherent_dma_mask = ctx->dma_mask;
8aa5bcb6161206 Mikko Perttunen 2022-06-27  56  		dev_set_name(&ctx->dev, "host1x-ctx.%d", i);
8aa5bcb6161206 Mikko Perttunen 2022-06-27  57  		ctx->dev.bus = &host1x_context_device_bus_type;
8aa5bcb6161206 Mikko Perttunen 2022-06-27  58  		ctx->dev.parent = host1x->dev;
55879dad0f3ae8 Yang Yingliang  2022-11-26  59  		ctx->dev.release = host1x_memory_context_release;
8aa5bcb6161206 Mikko Perttunen 2022-06-27  60  
8aa5bcb6161206 Mikko Perttunen 2022-06-27  61  		dma_set_max_seg_size(&ctx->dev, UINT_MAX);
8aa5bcb6161206 Mikko Perttunen 2022-06-27  62  
8aa5bcb6161206 Mikko Perttunen 2022-06-27  63  		err = device_add(&ctx->dev);
8aa5bcb6161206 Mikko Perttunen 2022-06-27  64  		if (err) {
8aa5bcb6161206 Mikko Perttunen 2022-06-27  65  			dev_err(host1x->dev, "could not add context device %d: %d\n", i, err);
55879dad0f3ae8 Yang Yingliang  2022-11-26  66  			put_device(&ctx->dev);
55879dad0f3ae8 Yang Yingliang  2022-11-26  67  			goto unreg_devices;
8aa5bcb6161206 Mikko Perttunen 2022-06-27  68  		}
8aa5bcb6161206 Mikko Perttunen 2022-06-27  69  
8aa5bcb6161206 Mikko Perttunen 2022-06-27  70  		err = of_dma_configure_id(&ctx->dev, node, true, &i);
8aa5bcb6161206 Mikko Perttunen 2022-06-27  71  		if (err) {
8aa5bcb6161206 Mikko Perttunen 2022-06-27  72  			dev_err(host1x->dev, "IOMMU configuration failed for context device %d: %d\n",
8aa5bcb6161206 Mikko Perttunen 2022-06-27  73  				i, err);
55879dad0f3ae8 Yang Yingliang  2022-11-26  74  			device_unregister(&ctx->dev);
55879dad0f3ae8 Yang Yingliang  2022-11-26  75  			goto unreg_devices;
8aa5bcb6161206 Mikko Perttunen 2022-06-27  76  		}
8aa5bcb6161206 Mikko Perttunen 2022-06-27  77  
9026ba722360ce Thierry Reding  2022-11-17  78  		if (!tegra_dev_iommu_get_stream_id(&ctx->dev, &ctx->stream_id) ||
9026ba722360ce Thierry Reding  2022-11-17  79  		    !device_iommu_mapped(&ctx->dev)) {
8aa5bcb6161206 Mikko Perttunen 2022-06-27  80  			dev_err(host1x->dev, "Context device %d has no IOMMU!\n", i);
55879dad0f3ae8 Yang Yingliang  2022-11-26  81  			device_unregister(&ctx->dev);
55879dad0f3ae8 Yang Yingliang  2022-11-26 @82  			goto unreg_devices;

error code?

8aa5bcb6161206 Mikko Perttunen 2022-06-27  83  		}
8aa5bcb6161206 Mikko Perttunen 2022-06-27  84  	}
8aa5bcb6161206 Mikko Perttunen 2022-06-27  85  
8aa5bcb6161206 Mikko Perttunen 2022-06-27  86  	return 0;
8aa5bcb6161206 Mikko Perttunen 2022-06-27  87  
55879dad0f3ae8 Yang Yingliang  2022-11-26  88  unreg_devices:
8aa5bcb6161206 Mikko Perttunen 2022-06-27  89  	while (i--)
55879dad0f3ae8 Yang Yingliang  2022-11-26  90  		device_unregister(&cdl->devs[i].dev);
8aa5bcb6161206 Mikko Perttunen 2022-06-27  91  
8aa5bcb6161206 Mikko Perttunen 2022-06-27  92  	kfree(cdl->devs);
8466ff24a37a9a Yang Yingliang  2022-11-26  93  	cdl->devs = NULL;
8aa5bcb6161206 Mikko Perttunen 2022-06-27  94  	cdl->len = 0;
8aa5bcb6161206 Mikko Perttunen 2022-06-27  95  
8aa5bcb6161206 Mikko Perttunen 2022-06-27  96  	return err;
8aa5bcb6161206 Mikko Perttunen 2022-06-27  97  }

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests


^ permalink raw reply	[flat|nested] 5+ messages in thread
* [linux-next:master 8309/10976] drivers/gpu/host1x/context.c:82 host1x_memory_context_list_init() warn: missing error code 'err'
@ 2023-04-13  4:25 kernel test robot
  0 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2023-04-13  4:25 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp, Dan Carpenter

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: Linux Memory Management List <linux-mm@kvack.org>
TO: "Christian König" <christian.koenig@amd.com>
CC: Thierry Reding <treding@nvidia.com>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   7d8214bba44c1aa6a75921a09a691945d26a8d43
commit: f75d19827b731c6f24930ef77e5a46cf2242bc68 [8309/10976] drm/tegra: Allow compile test on !ARM v2
:::::: branch date: 23 hours ago
:::::: commit date: 9 days ago
config: xtensa-randconfig-m041-20230411 (https://download.01.org/0day-ci/archive/20230413/202304131214.MOOEMszN-lkp@intel.com/config)
compiler: xtensa-linux-gcc (GCC) 12.1.0

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Link: https://lore.kernel.org/r/202304131214.MOOEMszN-lkp@intel.com/

smatch warnings:
drivers/gpu/host1x/context.c:82 host1x_memory_context_list_init() warn: missing error code 'err'
drivers/gpu/host1x/dev.c:417 host1x_iommu_attach() warn: passing zero to 'ERR_PTR'

vim +/err +82 drivers/gpu/host1x/context.c

55879dad0f3ae8 Yang Yingliang  2022-11-26  20  
8aa5bcb6161206 Mikko Perttunen 2022-06-27  21  int host1x_memory_context_list_init(struct host1x *host1x)
8aa5bcb6161206 Mikko Perttunen 2022-06-27  22  {
8aa5bcb6161206 Mikko Perttunen 2022-06-27  23  	struct host1x_memory_context_list *cdl = &host1x->context_list;
8aa5bcb6161206 Mikko Perttunen 2022-06-27  24  	struct device_node *node = host1x->dev->of_node;
8aa5bcb6161206 Mikko Perttunen 2022-06-27  25  	struct host1x_memory_context *ctx;
8aa5bcb6161206 Mikko Perttunen 2022-06-27  26  	unsigned int i;
8aa5bcb6161206 Mikko Perttunen 2022-06-27  27  	int err;
8aa5bcb6161206 Mikko Perttunen 2022-06-27  28  
8aa5bcb6161206 Mikko Perttunen 2022-06-27  29  	cdl->devs = NULL;
8aa5bcb6161206 Mikko Perttunen 2022-06-27  30  	cdl->len = 0;
8aa5bcb6161206 Mikko Perttunen 2022-06-27  31  	mutex_init(&cdl->lock);
8aa5bcb6161206 Mikko Perttunen 2022-06-27  32  
8aa5bcb6161206 Mikko Perttunen 2022-06-27  33  	err = of_property_count_u32_elems(node, "iommu-map");
8aa5bcb6161206 Mikko Perttunen 2022-06-27  34  	if (err < 0)
8aa5bcb6161206 Mikko Perttunen 2022-06-27  35  		return 0;
8aa5bcb6161206 Mikko Perttunen 2022-06-27  36  
8aa5bcb6161206 Mikko Perttunen 2022-06-27  37  	cdl->devs = kcalloc(err, sizeof(*cdl->devs), GFP_KERNEL);
8aa5bcb6161206 Mikko Perttunen 2022-06-27  38  	if (!cdl->devs)
8aa5bcb6161206 Mikko Perttunen 2022-06-27  39  		return -ENOMEM;
8aa5bcb6161206 Mikko Perttunen 2022-06-27  40  	cdl->len = err / 4;
8aa5bcb6161206 Mikko Perttunen 2022-06-27  41  
8aa5bcb6161206 Mikko Perttunen 2022-06-27  42  	for (i = 0; i < cdl->len; i++) {
8aa5bcb6161206 Mikko Perttunen 2022-06-27  43  		ctx = &cdl->devs[i];
8aa5bcb6161206 Mikko Perttunen 2022-06-27  44  
8aa5bcb6161206 Mikko Perttunen 2022-06-27  45  		ctx->host = host1x;
8aa5bcb6161206 Mikko Perttunen 2022-06-27  46  
8aa5bcb6161206 Mikko Perttunen 2022-06-27  47  		device_initialize(&ctx->dev);
8aa5bcb6161206 Mikko Perttunen 2022-06-27  48  
8aa5bcb6161206 Mikko Perttunen 2022-06-27  49  		/*
8aa5bcb6161206 Mikko Perttunen 2022-06-27  50  		 * Due to an issue with T194 NVENC, only 38 bits can be used.
8aa5bcb6161206 Mikko Perttunen 2022-06-27  51  		 * Anyway, 256GiB of IOVA ought to be enough for anyone.
8aa5bcb6161206 Mikko Perttunen 2022-06-27  52  		 */
8aa5bcb6161206 Mikko Perttunen 2022-06-27  53  		ctx->dma_mask = DMA_BIT_MASK(38);
8aa5bcb6161206 Mikko Perttunen 2022-06-27  54  		ctx->dev.dma_mask = &ctx->dma_mask;
8aa5bcb6161206 Mikko Perttunen 2022-06-27  55  		ctx->dev.coherent_dma_mask = ctx->dma_mask;
8aa5bcb6161206 Mikko Perttunen 2022-06-27  56  		dev_set_name(&ctx->dev, "host1x-ctx.%d", i);
8aa5bcb6161206 Mikko Perttunen 2022-06-27  57  		ctx->dev.bus = &host1x_context_device_bus_type;
8aa5bcb6161206 Mikko Perttunen 2022-06-27  58  		ctx->dev.parent = host1x->dev;
55879dad0f3ae8 Yang Yingliang  2022-11-26  59  		ctx->dev.release = host1x_memory_context_release;
8aa5bcb6161206 Mikko Perttunen 2022-06-27  60  
8aa5bcb6161206 Mikko Perttunen 2022-06-27  61  		dma_set_max_seg_size(&ctx->dev, UINT_MAX);
8aa5bcb6161206 Mikko Perttunen 2022-06-27  62  
8aa5bcb6161206 Mikko Perttunen 2022-06-27  63  		err = device_add(&ctx->dev);
8aa5bcb6161206 Mikko Perttunen 2022-06-27  64  		if (err) {
8aa5bcb6161206 Mikko Perttunen 2022-06-27  65  			dev_err(host1x->dev, "could not add context device %d: %d\n", i, err);
55879dad0f3ae8 Yang Yingliang  2022-11-26  66  			put_device(&ctx->dev);
55879dad0f3ae8 Yang Yingliang  2022-11-26  67  			goto unreg_devices;
8aa5bcb6161206 Mikko Perttunen 2022-06-27  68  		}
8aa5bcb6161206 Mikko Perttunen 2022-06-27  69  
8aa5bcb6161206 Mikko Perttunen 2022-06-27  70  		err = of_dma_configure_id(&ctx->dev, node, true, &i);
8aa5bcb6161206 Mikko Perttunen 2022-06-27  71  		if (err) {
8aa5bcb6161206 Mikko Perttunen 2022-06-27  72  			dev_err(host1x->dev, "IOMMU configuration failed for context device %d: %d\n",
8aa5bcb6161206 Mikko Perttunen 2022-06-27  73  				i, err);
55879dad0f3ae8 Yang Yingliang  2022-11-26  74  			device_unregister(&ctx->dev);
55879dad0f3ae8 Yang Yingliang  2022-11-26  75  			goto unreg_devices;
8aa5bcb6161206 Mikko Perttunen 2022-06-27  76  		}
8aa5bcb6161206 Mikko Perttunen 2022-06-27  77  
9026ba722360ce Thierry Reding  2022-11-17  78  		if (!tegra_dev_iommu_get_stream_id(&ctx->dev, &ctx->stream_id) ||
9026ba722360ce Thierry Reding  2022-11-17  79  		    !device_iommu_mapped(&ctx->dev)) {
8aa5bcb6161206 Mikko Perttunen 2022-06-27  80  			dev_err(host1x->dev, "Context device %d has no IOMMU!\n", i);
55879dad0f3ae8 Yang Yingliang  2022-11-26  81  			device_unregister(&ctx->dev);
55879dad0f3ae8 Yang Yingliang  2022-11-26 @82  			goto unreg_devices;
8aa5bcb6161206 Mikko Perttunen 2022-06-27  83  		}
8aa5bcb6161206 Mikko Perttunen 2022-06-27  84  	}
8aa5bcb6161206 Mikko Perttunen 2022-06-27  85  
8aa5bcb6161206 Mikko Perttunen 2022-06-27  86  	return 0;
8aa5bcb6161206 Mikko Perttunen 2022-06-27  87  
55879dad0f3ae8 Yang Yingliang  2022-11-26  88  unreg_devices:
8aa5bcb6161206 Mikko Perttunen 2022-06-27  89  	while (i--)
55879dad0f3ae8 Yang Yingliang  2022-11-26  90  		device_unregister(&cdl->devs[i].dev);
8aa5bcb6161206 Mikko Perttunen 2022-06-27  91  
8aa5bcb6161206 Mikko Perttunen 2022-06-27  92  	kfree(cdl->devs);
8466ff24a37a9a Yang Yingliang  2022-11-26  93  	cdl->devs = NULL;
8aa5bcb6161206 Mikko Perttunen 2022-06-27  94  	cdl->len = 0;
8aa5bcb6161206 Mikko Perttunen 2022-06-27  95  
8aa5bcb6161206 Mikko Perttunen 2022-06-27  96  	return err;
8aa5bcb6161206 Mikko Perttunen 2022-06-27  97  }
8aa5bcb6161206 Mikko Perttunen 2022-06-27  98  

:::::: The code at line 82 was first introduced by commit
:::::: 55879dad0f3ae8468444b42f785ad79eac05fe5b gpu: host1x: Fix memory leak of device names

:::::: TO: Yang Yingliang <yangyingliang@huawei.com>
:::::: CC: Thierry Reding <treding@nvidia.com>

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-04-13  9:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-13  5:06 [linux-next:master 8309/10976] drivers/gpu/host1x/context.c:82 host1x_memory_context_list_init() warn: missing error code 'err' Dan Carpenter
2023-04-13  8:57 ` Thierry Reding
2023-04-13  9:05   ` Dan Carpenter
2023-04-13  9:20     ` Thierry Reding
  -- strict thread matches above, loose matches on Subject: below --
2023-04-13  4:25 kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.