sonic-buildimage/platform/mellanox/non-upstream-patches/patches/0216-UBUNTU-SAUCE-mlxbf_pmc-Fix-references-to-sprintf.patch
Kebo Liu e286869b24
[Mellanox] Update HW-MGMT package to new version V.7.0030.1011 (#16239)
- Why I did it
1. Update Mellanox HW-MGMT package to newer version V.7.0030.1011
2. Replace the SONiC PMON Thermal control algorithm with the one inside the HW-MGMT package on all Nvidia platforms
3. Support Spectrum-4 systems

- How I did it
1. Update the HW-MGMT package version number and submodule pointer
2. Remove the thermal control algorithm implementation from Mellanox platform API
3. Revise the patch to HW-MGMT package which will disable HW-MGMT from running on SIMX
4. Update the downstream kernel patch list

Signed-off-by: Kebo Liu <kebol@nvidia.com>
2023-09-06 11:32:08 +03:00

70 lines
2.2 KiB
Diff

From 597a665f88fd16c595dd804c7567ccd5aab34ad9 Mon Sep 17 00:00:00 2001
From: Jitendra Lanka <jlanka@nvidia.com>
Date: Tue, 16 Aug 2022 16:18:39 -0400
Subject: [PATCH backport 5.10 17/63] UBUNTU: SAUCE: mlxbf_pmc: Fix references
to sprintf
BugLink: https://bugs.launchpad.net/bugs/1986849
Replace sprintf with snprintf with a defined upper boundary of
PAGE_SIZE for sysfs store/show functions and max array size defined
otherwise.
Change-Id: If586302684d60a435abc9f5aaf28b08de9b2df16
Signed-off-by: Jitendra Lanka <jlanka@nvidia.com>
Signed-off-by: Ike Panhc <ike.pan@canonical.com>
---
drivers/platform/mellanox/mlxbf-pmc.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/drivers/platform/mellanox/mlxbf-pmc.c b/drivers/platform/mellanox/mlxbf-pmc.c
index a9debcdf9..3305d2a5d 100644
--- a/drivers/platform/mellanox/mlxbf-pmc.c
+++ b/drivers/platform/mellanox/mlxbf-pmc.c
@@ -681,7 +681,7 @@ static ssize_t mlxbf_counter_read(struct kobject *ko,
} else
return -EINVAL;
- return sprintf(buf, "0x%llx\n", value);
+ return snprintf(buf, PAGE_SIZE, "0x%llx\n", value);
}
/* Store function for "counter" sysfs files */
@@ -758,7 +758,7 @@ static ssize_t mlxbf_event_find(struct kobject *ko,
evt_name = mlxbf_pmc_get_event_name((char *)ko->name, evt_num);
- return sprintf(buf, "0x%llx: %s\n", evt_num, evt_name);
+ return snprintf(buf, PAGE_SIZE, "0x%llx: %s\n", evt_num, evt_name);
}
/* Store function for "event" sysfs files */
@@ -811,9 +811,12 @@ static ssize_t mlxbf_print_event_list(struct kobject *ko,
buf[0] = '\0';
while (events[i].evt_name != NULL) {
- size += sprintf(e_info, "%x: %s\n", events[i].evt_num,
- events[i].evt_name);
- if (size > PAGE_SIZE)
+ size += snprintf(e_info,
+ sizeof(e_info),
+ "%x: %s\n",
+ events[i].evt_num,
+ events[i].evt_name);
+ if (size >= PAGE_SIZE)
break;
strcat(buf, e_info);
ret = size;
@@ -840,7 +843,7 @@ static ssize_t mlxbf_show_counter_state(struct kobject *ko,
value = FIELD_GET(MLXBF_L3C_PERF_CNT_CFG__EN, perfcnt_cfg);
- return sprintf(buf, "%d\n", value);
+ return snprintf(buf, PAGE_SIZE, "%d\n", value);
}
/* Store function for "enable" sysfs files - only for l3cache */
--
2.20.1