The following issues were found
drivers/clk/axis/clk-artpec6.c
3 issues
Line: 28
Column: 14
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
static struct artpec6_clkctrl_drvdata *clkdata;
static const char *const i2s_clk_names[NUM_I2S_CLOCKS] = {
"i2s0",
"i2s1",
};
static const int i2s_clk_indexes[NUM_I2S_CLOCKS] = {
Reported by FlawFinder.
Line: 124
Column: 8
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
struct clk **clks = clkdata->clk_table;
const char *sys_refclk_name;
const char *i2s_refclk_name = NULL;
const char *frac_clk_name[2] = { NULL, NULL };
const char *i2s_mux_parents[2];
u32 muxreg;
int i;
int err = 0;
Reported by FlawFinder.
Line: 125
Column: 8
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
const char *sys_refclk_name;
const char *i2s_refclk_name = NULL;
const char *frac_clk_name[2] = { NULL, NULL };
const char *i2s_mux_parents[2];
u32 muxreg;
int i;
int err = 0;
/* Mandatory parent clock. */
Reported by FlawFinder.
drivers/gpu/drm/drm_dp_helper.c
3 issues
Line: 618
Column: 2
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
drm_dbg_kms(aux->drm_dev, "%s: Base DPCD: %*ph\n", aux->name, DP_RECEIVER_CAP_SIZE, dpcd);
memcpy(dpcd, dpcd_ext, sizeof(dpcd_ext));
return 0;
}
/**
Reported by FlawFinder.
Line: 1053
Column: 50
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
*
* Returns branch device id on success or NULL on failure
*/
int drm_dp_downstream_id(struct drm_dp_aux *aux, char id[6])
{
return drm_dp_dpcd_read(aux, DP_BRANCH_ID, id, 6);
}
EXPORT_SYMBOL(drm_dp_downstream_id);
Reported by FlawFinder.
Line: 1078
Column: 2
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
DP_DETAILED_CAP_INFO_AVAILABLE;
int clk;
int bpc;
char id[7];
int len;
uint8_t rev[2];
int type = port_cap[0] & DP_DS_PORT_TYPE_MASK;
bool branch_device = drm_dp_is_branch(dpcd);
Reported by FlawFinder.
drivers/auxdisplay/img-ascii-lcd.c
3 issues
Line: 319
Column: 9
CWE codes:
120
Suggestion:
Use sprintf_s, snprintf, or vsnprintf
{
struct img_ascii_lcd_ctx *ctx = dev_get_drvdata(dev);
return sprintf(buf, "%s\n", ctx->message);
}
/**
* message_store() - write a new message via sysfs
* @dev: the LCD device
Reported by FlawFinder.
Line: 287
Column: 2
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
if (!new_msg)
return -ENOMEM;
memcpy(new_msg, msg, count);
new_msg[count] = 0;
if (ctx->message)
devm_kfree(&ctx->pdev->dev, ctx->message);
Reported by FlawFinder.
Line: 277
Column: 11
CWE codes:
126
del_timer_sync(&ctx->timer);
if (count == -1)
count = strlen(msg);
/* if the string ends with a newline, trim it */
if (msg[count - 1] == '\n')
count--;
Reported by FlawFinder.
drivers/acpi/event.c
3 issues
Line: 31
Column: 2
CWE codes:
120
Suggestion:
Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused)
{
struct acpi_bus_event event;
strcpy(event.device_class, dev->pnp.device_class);
strcpy(event.bus_id, dev->pnp.bus_id);
event.type = type;
event.data = data;
return (blocking_notifier_call_chain(&acpi_chain_head, 0, (void *)&event)
== NOTIFY_BAD) ? -EINVAL : 0;
Reported by FlawFinder.
Line: 32
Column: 2
CWE codes:
120
Suggestion:
Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused)
struct acpi_bus_event event;
strcpy(event.device_class, dev->pnp.device_class);
strcpy(event.bus_id, dev->pnp.bus_id);
event.type = type;
event.data = data;
return (blocking_notifier_call_chain(&acpi_chain_head, 0, (void *)&event)
== NOTIFY_BAD) ? -EINVAL : 0;
}
Reported by FlawFinder.
Line: 56
Column: 2
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
static unsigned int acpi_event_seqnum;
struct acpi_genl_event {
acpi_device_class device_class;
char bus_id[15];
u32 type;
u32 data;
};
/* attributes of acpi_genl_family */
Reported by FlawFinder.
tools/perf/builtin-config.c
3 issues
Line: 160
Column: 47
CWE codes:
807
20
Suggestion:
Check environment variables carefully before using them
{
int i, ret = -1;
struct perf_config_set *set;
char *user_config = mkpath("%s/.perfconfig", getenv("HOME"));
const char *config_filename;
bool changed = false;
argc = parse_options(argc, argv, config_options, config_usage,
PARSE_OPT_STOP_AT_NON_OPTION);
Reported by FlawFinder.
Line: 47
Column: 7
CWE codes:
362
if (set == NULL)
return -1;
fp = fopen(file_name, "w");
if (!fp)
return -1;
fprintf(fp, "%s\n", first_line);
Reported by FlawFinder.
Line: 85
Column: 29
CWE codes:
126
continue;
perf_config_items__for_each_entry(§ion->items, item) {
const char *name = var + strlen(section->name) + 1;
if (strcmp(name, item->name) == 0) {
char *value = item->value;
if (value) {
Reported by FlawFinder.
tools/perf/tests/topology.c
3 issues
Line: 21
Column: 2
CWE codes:
120
Suggestion:
Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused)
{
int fd;
strcpy(path, TEMPL);
fd = mkstemp(path);
if (fd < 0) {
perror("mkstemp failed");
return -1;
Reported by FlawFinder.
Line: 23
Column: 7
CWE codes:
377
strcpy(path, TEMPL);
fd = mkstemp(path);
if (fd < 0) {
perror("mkstemp failed");
return -1;
}
Reported by FlawFinder.
Line: 178
Column: 2
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
int test__session_topology(struct test *test __maybe_unused, int subtest __maybe_unused)
{
char path[PATH_MAX];
struct perf_cpu_map *map;
int ret = TEST_FAIL;
TEST_ASSERT_VAL("can't get templ file", !get_temp(path));
Reported by FlawFinder.
tools/testing/selftests/bpf/prog_tests/test_bpffs.c
3 issues
Line: 15
Column: 2
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
static int read_iter(char *file)
{
/* 1024 should be enough to get contiguous 4 "iter" letters at some point */
char buf[1024];
int fd, len;
fd = open(file, 0);
if (fd < 0)
return -1;
Reported by FlawFinder.
Line: 18
Column: 7
CWE codes:
362
char buf[1024];
int fd, len;
fd = open(file, 0);
if (fd < 0)
return -1;
while ((len = read(fd, buf, sizeof(buf))) > 0)
if (strstr(buf, "iter")) {
close(fd);
Reported by FlawFinder.
tools/power/cpupower/utils/idle_monitor/amd_fam14h_idle.c
3 issues
Line: 284
Column: 3
CWE codes:
120
return NULL;
if (cpupower_cpu_info.family == 0x14)
strncpy(amd_fam14h_monitor.name, "Fam_14h",
MONITOR_NAME_LEN - 1);
else if (cpupower_cpu_info.family == 0x12)
strncpy(amd_fam14h_monitor.name, "Fam_12h",
MONITOR_NAME_LEN - 1);
else
Reported by FlawFinder.
Line: 287
Column: 3
CWE codes:
120
strncpy(amd_fam14h_monitor.name, "Fam_14h",
MONITOR_NAME_LEN - 1);
else if (cpupower_cpu_info.family == 0x12)
strncpy(amd_fam14h_monitor.name, "Fam_12h",
MONITOR_NAME_LEN - 1);
else
return NULL;
/* We do not alloc for nbp1 machine wide counter */
Reported by FlawFinder.
Line: 309
Column: 32
CWE codes:
126
if (!is_nbp1_capable())
amd_fam14h_monitor.hw_states_num = AMD_FAM14H_STATE_NUM - 1;
amd_fam14h_monitor.name_len = strlen(amd_fam14h_monitor.name);
return &amd_fam14h_monitor;
}
static void amd_fam14h_unregister(void)
{
Reported by FlawFinder.
sound/usb/usx2y/usx2yhwdeppcm.h
3 issues
Line: 8
Column: 2
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
#define SSS (((MAXPACK*MAXBUFFERMS*MAXSTRIDE + 4096) / 4096) * 4096)
struct snd_usx2y_hwdep_pcm_shm {
char playback[SSS];
char capture0x8[SSS];
char capture0xA[SSS];
volatile int playback_iso_head;
int playback_iso_start;
struct {
Reported by FlawFinder.
Line: 9
Column: 2
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
#define SSS (((MAXPACK*MAXBUFFERMS*MAXSTRIDE + 4096) / 4096) * 4096)
struct snd_usx2y_hwdep_pcm_shm {
char playback[SSS];
char capture0x8[SSS];
char capture0xA[SSS];
volatile int playback_iso_head;
int playback_iso_start;
struct {
int frame,
Reported by FlawFinder.
Line: 10
Column: 2
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
struct snd_usx2y_hwdep_pcm_shm {
char playback[SSS];
char capture0x8[SSS];
char capture0xA[SSS];
volatile int playback_iso_head;
int playback_iso_start;
struct {
int frame,
offset,
Reported by FlawFinder.
tools/testing/selftests/arm64/mte/mte_common_util.c
3 issues
Line: 176
Column: 2
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
void *mte_allocate_file_memory(size_t size, int mem_type, int mapping, bool tags, int fd)
{
int index;
char buffer[INIT_BUFFER_SIZE];
if (mem_type != USE_MPROTECT && mem_type != USE_MMAP) {
ksft_print_msg("FAIL: Invalid mmap file request\n");
return NULL;
}
Reported by FlawFinder.
Line: 202
Column: 2
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
size_t range_before, size_t range_after, int fd)
{
int index;
char buffer[INIT_BUFFER_SIZE];
int map_size = size + range_before + range_after;
if (mem_type != USE_MPROTECT && mem_type != USE_MMAP) {
ksft_print_msg("FAIL: Invalid mmap file request\n");
return NULL;
Reported by FlawFinder.
Line: 338
Column: 7
CWE codes:
377
char filename[] = "/dev/shm/tmp_XXXXXX";
/* Create a file in the tmpfs filesystem */
fd = mkstemp(&filename[0]);
if (fd == -1) {
perror(filename);
ksft_print_msg("FAIL: Unable to open temporary file\n");
return 0;
}
Reported by FlawFinder.