mirror of
git://nv-tegra.nvidia.com/linux-nv-oot.git
synced 2025-12-23 17:55:05 +03:00
nvadsp: os: CERT-C Fixes
Uploaded fix to address coverity issues. 1. Fix for string assignment to a char ptr (const) 2. Unsigned int type variable to hold AGIC IRQ number 3. Misc. : added error handling for null pointers Bug 3512545 CID : 407176, 339372, 426068, 349597, 408235, 468432, 425451, 339564, 340901, 360199, 482718, 338388, 434000, 488442, 355983, 437791, 444590, 409920, 423102, 416511, 426540, 392115, 451458, 355042, 443648, 420343, 423532, 488763, 476874, 404805, 380630, 358854, 485375, 483303, 462651, 371708, 465040, 447093, 406990, 335646, 437343, 467012, 378419, 428324, 354351, 460155, 415702, 376737, 390977, 414736, 411426, 393560, 490887 Change-Id: I5c847fa02438931e95107d06333014fb802c8207 Signed-off-by: Sharad Gupta <sharadg@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2672112 Tested-by: mobile promotions <svcmobile_promotions@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
Laxman Dewangan
parent
f90d551e16
commit
3ea7c9344c
@@ -234,7 +234,7 @@ struct nvadsp_drv_data {
|
|||||||
u32 adsp_mem[ADSP_MEM_END];
|
u32 adsp_mem[ADSP_MEM_END];
|
||||||
bool adsp_unit_fpga;
|
bool adsp_unit_fpga;
|
||||||
u32 unit_fpga_reset[ADSP_UNIT_FPGA_RESET_END];
|
u32 unit_fpga_reset[ADSP_UNIT_FPGA_RESET_END];
|
||||||
int agic_irqs[NVADSP_VIRQ_MAX];
|
u32 agic_irqs[NVADSP_VIRQ_MAX];
|
||||||
|
|
||||||
struct tegra_bwmgr_client *bwmgr;
|
struct tegra_bwmgr_client *bwmgr;
|
||||||
#if KERNEL_VERSION(5, 9, 0) <= LINUX_VERSION_CODE
|
#if KERNEL_VERSION(5, 9, 0) <= LINUX_VERSION_CODE
|
||||||
|
|||||||
@@ -446,6 +446,7 @@ static inline void __maybe_unused dump_global_symbol_table(void)
|
|||||||
"STT_FUNC" : "STT_OBJECT");
|
"STT_FUNC" : "STT_OBJECT");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_ANDROID
|
||||||
static int
|
static int
|
||||||
__maybe_unused create_global_symbol_table(const struct firmware *fw)
|
__maybe_unused create_global_symbol_table(const struct firmware *fw)
|
||||||
{
|
{
|
||||||
@@ -460,6 +461,11 @@ __maybe_unused create_global_symbol_table(const struct firmware *fw)
|
|||||||
struct elf32_sym *sym;
|
struct elf32_sym *sym;
|
||||||
struct elf32_sym *last_sym;
|
struct elf32_sym *last_sym;
|
||||||
|
|
||||||
|
if (!sym_shdr || !str_shdr) {
|
||||||
|
dev_dbg(dev, "section symtab/strtab not found!\n");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
sym = (struct elf32_sym *)(elf_data + sym_shdr->sh_offset);
|
sym = (struct elf32_sym *)(elf_data + sym_shdr->sh_offset);
|
||||||
name_table = elf_data + str_shdr->sh_offset;
|
name_table = elf_data + str_shdr->sh_offset;
|
||||||
|
|
||||||
@@ -487,6 +493,7 @@ __maybe_unused create_global_symbol_table(const struct firmware *fw)
|
|||||||
priv.adsp_glo_sym_tbl[0].addr = i;
|
priv.adsp_glo_sym_tbl[0].addr = i;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif /* CONFIG_ANDROID */
|
||||||
|
|
||||||
struct global_sym_info * __maybe_unused find_global_symbol(const char *sym_name)
|
struct global_sym_info * __maybe_unused find_global_symbol(const char *sym_name)
|
||||||
{
|
{
|
||||||
@@ -623,9 +630,6 @@ static void *nvadsp_dma_alloc_and_map_at(struct platform_device *pdev,
|
|||||||
{
|
{
|
||||||
struct iommu_domain *domain = iommu_get_domain_for_dev(&pdev->dev);
|
struct iommu_domain *domain = iommu_get_domain_for_dev(&pdev->dev);
|
||||||
unsigned long align_mask = ~0UL << fls_long(size - 1);
|
unsigned long align_mask = ~0UL << fls_long(size - 1);
|
||||||
unsigned long shift = __ffs(domain->pgsize_bitmap);
|
|
||||||
unsigned long pg_size = 1UL << shift;
|
|
||||||
unsigned long mp_size = pg_size;
|
|
||||||
struct device *dev = &pdev->dev;
|
struct device *dev = &pdev->dev;
|
||||||
dma_addr_t aligned_iova = iova & align_mask;
|
dma_addr_t aligned_iova = iova & align_mask;
|
||||||
dma_addr_t end = iova + size;
|
dma_addr_t end = iova + size;
|
||||||
@@ -633,6 +637,16 @@ static void *nvadsp_dma_alloc_and_map_at(struct platform_device *pdev,
|
|||||||
phys_addr_t pa, pa_new;
|
phys_addr_t pa, pa_new;
|
||||||
void *cpu_va;
|
void *cpu_va;
|
||||||
int ret;
|
int ret;
|
||||||
|
unsigned long shift = 0, pg_size = 0, mp_size = 0;
|
||||||
|
|
||||||
|
if (!domain) {
|
||||||
|
dev_err(dev, "Unable to get iommu_domain\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
shift = __ffs(domain->pgsize_bitmap);
|
||||||
|
pg_size = 1UL << shift;
|
||||||
|
mp_size = pg_size;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reserve iova range using aligned size: adsp memory might not start
|
* Reserve iova range using aligned size: adsp memory might not start
|
||||||
@@ -880,6 +894,10 @@ static int nvadsp_firmware_load(struct platform_device *pdev)
|
|||||||
drv_data->shared_adsp_os_data_iova = priv.adsp_os_addr;
|
drv_data->shared_adsp_os_data_iova = priv.adsp_os_addr;
|
||||||
shared_mem = nvadsp_da_to_va_mappings(
|
shared_mem = nvadsp_da_to_va_mappings(
|
||||||
priv.adsp_os_addr, priv.adsp_os_size);
|
priv.adsp_os_addr, priv.adsp_os_size);
|
||||||
|
if (!shared_mem) {
|
||||||
|
dev_err(dev, "Failed to get VA for ADSP OS\n");
|
||||||
|
goto deallocate_os_memory;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
dev_err(dev, "failed to locate shared memory\n");
|
dev_err(dev, "failed to locate shared memory\n");
|
||||||
goto deallocate_os_memory;
|
goto deallocate_os_memory;
|
||||||
@@ -1456,7 +1474,7 @@ static void get_adsp_state(void)
|
|||||||
struct nvadsp_drv_data *drv_data;
|
struct nvadsp_drv_data *drv_data;
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
uint32_t val;
|
uint32_t val;
|
||||||
char *msg;
|
const char *msg;
|
||||||
|
|
||||||
if (!priv.pdev) {
|
if (!priv.pdev) {
|
||||||
pr_err("ADSP Driver is not initialized\n");
|
pr_err("ADSP Driver is not initialized\n");
|
||||||
@@ -1651,8 +1669,8 @@ EXPORT_SYMBOL(dump_adsp_sys);
|
|||||||
static void nvadsp_free_os_interrupts(struct nvadsp_os_data *priv)
|
static void nvadsp_free_os_interrupts(struct nvadsp_os_data *priv)
|
||||||
{
|
{
|
||||||
struct nvadsp_drv_data *drv_data = platform_get_drvdata(priv->pdev);
|
struct nvadsp_drv_data *drv_data = platform_get_drvdata(priv->pdev);
|
||||||
int wdt_virq = drv_data->agic_irqs[WDT_VIRQ];
|
unsigned int wdt_virq = drv_data->agic_irqs[WDT_VIRQ];
|
||||||
int wfi_virq = drv_data->agic_irqs[WFI_VIRQ];
|
unsigned int wfi_virq = drv_data->agic_irqs[WFI_VIRQ];
|
||||||
struct device *dev = &priv->pdev->dev;
|
struct device *dev = &priv->pdev->dev;
|
||||||
|
|
||||||
devm_free_irq(dev, wdt_virq, priv);
|
devm_free_irq(dev, wdt_virq, priv);
|
||||||
@@ -1662,8 +1680,8 @@ static void nvadsp_free_os_interrupts(struct nvadsp_os_data *priv)
|
|||||||
static int nvadsp_setup_os_interrupts(struct nvadsp_os_data *priv)
|
static int nvadsp_setup_os_interrupts(struct nvadsp_os_data *priv)
|
||||||
{
|
{
|
||||||
struct nvadsp_drv_data *drv_data = platform_get_drvdata(priv->pdev);
|
struct nvadsp_drv_data *drv_data = platform_get_drvdata(priv->pdev);
|
||||||
int wdt_virq = drv_data->agic_irqs[WDT_VIRQ];
|
unsigned int wdt_virq = drv_data->agic_irqs[WDT_VIRQ];
|
||||||
int wfi_virq = drv_data->agic_irqs[WFI_VIRQ];
|
unsigned int wfi_virq = drv_data->agic_irqs[WFI_VIRQ];
|
||||||
struct device *dev = &priv->pdev->dev;
|
struct device *dev = &priv->pdev->dev;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@@ -2064,7 +2082,7 @@ static void nvadsp_os_restart(struct work_struct *work)
|
|||||||
struct nvadsp_os_data *data =
|
struct nvadsp_os_data *data =
|
||||||
container_of(work, struct nvadsp_os_data, restart_os_work);
|
container_of(work, struct nvadsp_os_data, restart_os_work);
|
||||||
struct nvadsp_drv_data *drv_data = platform_get_drvdata(data->pdev);
|
struct nvadsp_drv_data *drv_data = platform_get_drvdata(data->pdev);
|
||||||
int wdt_virq = drv_data->agic_irqs[WDT_VIRQ];
|
unsigned int wdt_virq = drv_data->agic_irqs[WDT_VIRQ];
|
||||||
int wdt_irq = drv_data->chip_data->wdt_irq;
|
int wdt_irq = drv_data->chip_data->wdt_irq;
|
||||||
struct device *dev = &data->pdev->dev;
|
struct device *dev = &data->pdev->dev;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user