File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
drivers/platform/mellanox Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 15
15
#include <linux/hwmon.h>
16
16
#include <linux/platform_device.h>
17
17
#include <linux/string.h>
18
+ #include <linux/string_helpers.h>
18
19
#include <uapi/linux/psci.h>
19
20
20
21
#define MLXBF_PMC_WRITE_REG_32 0x82000009
@@ -1784,15 +1785,22 @@ static ssize_t mlxbf_pmc_event_store(struct device *dev,
1784
1785
attr , struct mlxbf_pmc_attribute , dev_attr );
1785
1786
unsigned int blk_num , cnt_num ;
1786
1787
bool is_l3 = false;
1788
+ char * evt_name ;
1787
1789
int evt_num ;
1788
1790
int err ;
1789
1791
1790
1792
blk_num = attr_event -> nr ;
1791
1793
cnt_num = attr_event -> index ;
1792
1794
1793
1795
if (isalpha (buf [0 ])) {
1796
+ /* Remove the trailing newline character if present */
1797
+ evt_name = kstrdup_and_replace (buf , '\n' , '\0' , GFP_KERNEL );
1798
+ if (!evt_name )
1799
+ return - ENOMEM ;
1800
+
1794
1801
evt_num = mlxbf_pmc_get_event_num (pmc -> block_name [blk_num ],
1795
- buf );
1802
+ evt_name );
1803
+ kfree (evt_name );
1796
1804
if (evt_num < 0 )
1797
1805
return - EINVAL ;
1798
1806
} else {
You can’t perform that action at this time.
0 commit comments