[bug report] gpu: host1x: Fix memory leak of device names

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[ What's going on with tegra and old warnings??? ]

Hello Yang Yingliang,

The patch 55879dad0f3a: "gpu: host1x: Fix memory leak of device
names" from Nov 26, 2022, leads to the following Smatch static
checker warning:

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

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

Error code?

    83                 }
    84         }
    85 
    86         return 0;
    87 
    88 unreg_devices:
    89         while (i--)
    90                 device_unregister(&cdl->devs[i].dev);
    91 
    92         kfree(cdl->devs);
    93         cdl->devs = NULL;
    94         cdl->len = 0;
    95 
    96         return err;
    97 }

regards,
dan carpenter



[Index of Archives]     [ARM Kernel]     [Linux ARM]     [Linux ARM MSM]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux