gpu: nvgpu: Fix Unchecked Return Value bugs

Propagate errors from previously unchecked function calls.
This fixes the following Coverity Defects:

nvlink.c : Unchecked return value
sysfs.c : Unchecked return value
nvlink_probe.c : Unchecked return value
ioctl_nvs.c : Unchecked return value

CID 9847567
CID 9848580
CID 10127940
CID 10129447

Bug 3460991
Signed-off-by: Jinesh Parakh <jparakh@nvidia.com>
Change-Id: I930bf34a451d6d941359ad76c84cf1fef2df1351
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2689111
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Jinesh Parakh
2022-03-29 15:15:09 +05:30
committed by mobile promotions
parent 120a653dd1
commit 02b108d26d
4 changed files with 71 additions and 18 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2018-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,16 +219,24 @@ int nvgpu_nvlink_minion_load_ucode(struct gk20a *g,
" - Ucode Data Size = %u", minion_hdr->ucode_data_size);
/* Copy Non Secure IMEM code */
nvgpu_falcon_copy_to_imem(&g->minion_flcn, 0,
err = nvgpu_falcon_copy_to_imem(&g->minion_flcn, 0,
(u8 *)&ndev->minion_img[minion_hdr->os_code_offset],
minion_hdr->os_code_size, 0, false,
GET_IMEM_TAG(minion_hdr->os_code_offset));
if (err != 0) {
goto exit;
}
/* Copy Non Secure DMEM code */
nvgpu_falcon_copy_to_dmem(&g->minion_flcn, 0,
err = nvgpu_falcon_copy_to_dmem(&g->minion_flcn, 0,
(u8 *)&ndev->minion_img[minion_hdr->os_data_offset],
minion_hdr->os_data_size, 0);
if (err != 0) {
goto exit;
}
/* Load the apps securely */
for (app = 0; app < minion_hdr->num_apps; app++) {
u32 app_code_start = minion_hdr->app_code_offsets[app];
@@ -236,20 +244,31 @@ int nvgpu_nvlink_minion_load_ucode(struct gk20a *g,
u32 app_data_start = minion_hdr->app_data_offsets[app];
u32 app_data_size = minion_hdr->app_data_sizes[app];
if (app_code_size)
nvgpu_falcon_copy_to_imem(&g->minion_flcn,
if (app_code_size) {
err = nvgpu_falcon_copy_to_imem(&g->minion_flcn,
app_code_start,
(u8 *)&ndev->minion_img[app_code_start],
app_code_size, 0, true,
GET_IMEM_TAG(app_code_start));
if (app_data_size)
nvgpu_falcon_copy_to_dmem(&g->minion_flcn,
if (err != 0) {
goto exit;
}
}
if (app_data_size) {
err = nvgpu_falcon_copy_to_dmem(&g->minion_flcn,
app_data_start,
(u8 *)&ndev->minion_img[app_data_start],
app_data_size, 0);
if (err != 0) {
goto exit;
}
}
}
exit:
return err;
}