diff --git a/drivers/platform/tegra/nvadsp/app.c b/drivers/platform/tegra/nvadsp/app.c index 12634b76..38dac101 100644 --- a/drivers/platform/tegra/nvadsp/app.c +++ b/drivers/platform/tegra/nvadsp/app.c @@ -3,7 +3,7 @@ * * ADSP OS App management * - * Copyright (C) 2014-2021, NVIDIA Corporation. All rights reserved. + * Copyright (C) 2014-2022, NVIDIA Corporation. All rights reserved. * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and @@ -425,8 +425,13 @@ static int create_instance_memory(nvadsp_app_info_t *app, char name[NVADSP_NAME_SZ]; void *aram_handle; dma_addr_t da; + int ret; - snprintf(name, NVADSP_NAME_SZ, "%s:%d", app->name, app->instance_id); + ret = snprintf(name, NVADSP_NAME_SZ, "%s:%d", app->name, app->instance_id); + if (ret < 0 || ret >= NVADSP_NAME_SZ) { + dev_err(dev, "Invalid App name %s\n", app->name); + return -EINVAL; + } if (sz->dram) { mem->dram = nvadsp_alloc_coherent(sz->dram, &da, GFP_KERNEL); diff --git a/drivers/platform/tegra/nvadsp/app_loader_linker.c b/drivers/platform/tegra/nvadsp/app_loader_linker.c index 083a0d4a..cfd8d193 100644 --- a/drivers/platform/tegra/nvadsp/app_loader_linker.c +++ b/drivers/platform/tegra/nvadsp/app_loader_linker.c @@ -893,7 +893,7 @@ struct adsp_module *load_adsp_dynamic_module(const char *appname, /* Figure out module layout, and allocate all the memory. */ mod = layout_and_allocate(&info); - if (IS_ERR(mod)) + if (IS_ERR_OR_NULL(mod)) goto error_free_memory; /* update adsp specific sections */ diff --git a/drivers/platform/tegra/nvadsp/os.c b/drivers/platform/tegra/nvadsp/os.c index 7a472532..7bb55ee4 100644 --- a/drivers/platform/tegra/nvadsp/os.c +++ b/drivers/platform/tegra/nvadsp/os.c @@ -332,7 +332,7 @@ bool is_adsp_dram_addr(u64 addr) int nvadsp_add_load_mappings(phys_addr_t pa, void *mapping, int len) { - if (map_idx >= NM_LOAD_MAPPINGS) + if (map_idx < 0 || map_idx >= NM_LOAD_MAPPINGS) return -EINVAL; adsp_map[map_idx].da = pa; @@ -884,7 +884,7 @@ static int nvadsp_firmware_load(struct platform_device *pdev) } shared_mem = get_mailbox_shared_region(fw); - if (IS_ERR(shared_mem)) { + if (IS_ERR_OR_NULL(shared_mem)) { if (drv_data->chip_data->adsp_shared_mem_hwmbox != 0) { /* * If FW is not explicitly defining a shared memory