diff --git a/drivers/video/tegra/virt/tegra_gr_comm.c b/drivers/video/tegra/virt/tegra_gr_comm.c index 95435c56..9e931dac 100644 --- a/drivers/video/tegra/virt/tegra_gr_comm.c +++ b/drivers/video/tegra/virt/tegra_gr_comm.c @@ -1,7 +1,7 @@ /* * Tegra Graphics Virtualization Communication Framework * - * Copyright (c) 2013-2021, NVIDIA Corporation. All rights reserved. + * Copyright (c) 2013-2022, NVIDIA Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -219,7 +219,11 @@ static int setup_mempool(struct platform_device *pdev, char name[20]; u32 inst; - snprintf(name, sizeof(name), "mempool%d", i); + if (snprintf(name, sizeof(name), "mempool%d", i) < 0) { + ret = -ENOMEM; + goto fail; + } + if (of_property_read_u32_index(dev->of_node, name, PROP_MEMPOOL_INST, &inst) == 0) { struct gr_comm_mempool_context *ctx; @@ -268,7 +272,11 @@ static int setup_ivc(struct platform_device *pdev, char name[20]; u32 inst; - snprintf(name, sizeof(name), "ivc-queue%d", i); + if (snprintf(name, sizeof(name), "ivc-queue%d", i) < 0) { + ret = -ENOMEM; + goto fail; + } + if (of_property_read_u32_index(dev->of_node, name, PROP_IVC_INST, &inst) == 0) { struct device_node *hv_dn; @@ -359,7 +367,11 @@ int tegra_gr_comm_init(struct platform_device *pdev, u32 elems, if (queue->valid) return -EEXIST; - snprintf(name, sizeof(name), "gr-virt-comm-%d", i); + if (snprintf(name, sizeof(name), "gr-virt-comm-%d", i) < 0) { + ret = -ENOMEM; + goto fail; + } + queue->element_cache = kmem_cache_create(name, sizeof(struct gr_comm_element) + size, 0,