nvadsp: Add err check in ADSP ELF string copy

Error check is added to prevent out-of-bound access
when copying ADSP ELF string from DT.

Fixes Coverity defect CID 10132209.

Bug 3461002
Bug 200746669
Bug 200773359

Change-Id: I56beabcf8d78aed560cde523dee0429acd784dc9
Signed-off-by: Viswanath L <viswanathl@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2664843
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
GVS: Gerrit_Virtual_Submit
This commit is contained in:
Viswanath L
2022-02-07 13:01:13 +05:30
committed by Laxman Dewangan
parent a99d68a86e
commit 7835064bc3

View File

@@ -289,9 +289,14 @@ static int __init nvadsp_parse_dt(struct platform_device *pdev)
}
if (!of_property_read_string(dev->of_node,
"nvidia,adsp_elf", &adsp_elf))
strcpy(drv_data->adsp_elf, adsp_elf);
else
"nvidia,adsp_elf", &adsp_elf)) {
if (strlen(adsp_elf) < MAX_FW_STR)
strcpy(drv_data->adsp_elf, adsp_elf);
else {
dev_err(dev, "invalid string in nvidia,adsp_elf\n");
return -EINVAL;
}
} else
strcpy(drv_data->adsp_elf, NVADSP_ELF);
drv_data->adsp_unit_fpga = of_property_read_bool(dev->of_node,