tegra: hwpm: fix reported coverity violations

- Declare and initialize timeout and mem_bytes_kernel_u32 variables.
- alist_map NULL pointer check is done after alist_map structure
references. Modify update_allowlist ioctl and release alist_map
functions to check alist_map NULL pointer before it's use.
- Checking if unsigned _IOC_NR(cmd) is less than zero has no effect.
Remove this check.
- Correct printf format specifier for mem_bytes_addr.

Bug 3461002

Change-Id: I79a97942e667c173d112bcaafb14ddcb8dd7d47f
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2765676
Reviewed-by: Vasuki Shankar <vasukis@nvidia.com>
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Vedashree Vidwans
2022-08-23 14:27:43 -07:00
committed by mobile promotions
parent d58dbfe5a9
commit 14d527e97a
4 changed files with 51 additions and 38 deletions

View File

@@ -22,14 +22,28 @@ int tegra_hwpm_get_allowlist_size(struct tegra_soc_hwpm *hwpm)
{
int ret = 0;
hwpm->alist_map->full_alist_size = 0ULL;
tegra_hwpm_fn(hwpm, " ");
ret = tegra_hwpm_func_all_ip(hwpm, NULL, TEGRA_HWPM_GET_ALIST_SIZE);
if (ret != 0) {
tegra_hwpm_err(hwpm, "get_alist_size failed");
return ret;
if (hwpm->alist_map == NULL) {
/* Allocate tegra_hwpm_allowlist_map */
hwpm->alist_map = tegra_hwpm_kzalloc(hwpm,
sizeof(struct tegra_hwpm_allowlist_map));
if (!hwpm->alist_map) {
tegra_hwpm_err(NULL,
"Couldn't allocate allowlist map structure");
return -ENOMEM;
}
hwpm->alist_map->full_alist_size = 0ULL;
}
if (hwpm->alist_map->full_alist_size == 0) {
/* Full alist size is not computed yet */
ret = tegra_hwpm_func_all_ip(hwpm, NULL,
TEGRA_HWPM_GET_ALIST_SIZE);
if (ret != 0) {
tegra_hwpm_err(hwpm, "get_alist_size failed");
return ret;
}
}
return 0;