drivers: devfreq: Fix CERT-C Violations

Fix the following CERT-C Violations:
governor_pod_scaling_v2.c : CERT ERR33-C

The violations occur due to non-verification of the snprintf
return values.
Adding WARN_ON statements to verify the return values.

CID 378002
CID 391305
CID 442828
CID 443110

Bug 3512546

Signed-off-by: Jinesh Parakh <jparakh@nvidia.com>
Change-Id: I91c35ecce9348d4f7127eafa603d2b8c2391ba18
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2723684
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Jinesh Parakh
2022-06-02 12:05:53 +05:30
committed by Laxman Dewangan
parent 8a2d6e1b54
commit 19de6baf19

View File

@@ -445,9 +445,11 @@ static void nvhost_scale_emc_debug_init(struct devfreq *df)
{
struct podgov_info_rec *podgov = df->data;
char dirname[128];
int err;
snprintf(dirname, sizeof(dirname), "%s_scaling",
err = snprintf(dirname, sizeof(dirname), "%s_scaling",
to_platform_device(df->dev.parent)->name);
WARN_ON(err < 0);
if (!podgov)
return;
@@ -506,6 +508,7 @@ static ssize_t enable_3d_scaling_show(struct kobject *kobj,
ssize_t res;
res = snprintf(buf, PAGE_SIZE, "%d\n", podgov->enable);
WARN_ON(res < 0);
return res;
}
@@ -542,6 +545,7 @@ static ssize_t user_show(struct kobject *kobj,
ssize_t res;
res = snprintf(buf, PAGE_SIZE, "%d\n", podgov->p_user);
WARN_ON(res < 0);
return res;
}
@@ -571,6 +575,7 @@ static ssize_t freq_request_show(struct kobject *kobj,
ssize_t res;
res = snprintf(buf, PAGE_SIZE, "%d\n", podgov->p_freq_request);
WARN_ON(res < 0);
return res;
}